Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… hover query Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Why This is the industry standard: Tailwind CSS v4 applies its The |
@media (hover: hover) describes the primary pointer, so it doesn't prevent sticky hover on devices with both a touchscreen and a mouse or touchpad. Recommend the hover mixin and the data-whatintent check that the components use, and show how to keep focus styles visible after a tap.
The previous commit replaced a more complete version of this section.
The mixin now applies hover styles inside @media (any-hover: hover) unless the current input is touch or keyboard. Explain why any-hover is used instead of hover, and what happens before the input tracking starts.
Recommend :where() around the hover check for custom selectors, so pressed, disabled and error styles still win over hover. Add a bullet for resting styles that exclude :hover: they must apply exactly where hover styles are off.
The :where(html...) form breaks in scoped builds, where the scope class ends up before the html element. Restore the previous text until a form that keeps the specificity also works with style scoping.
langz
left a comment
There was a problem hiding this comment.
Review of fabd9cd: Changes needed
Since the last review (3e65085), 866f395 changed the custom-selector advice to a :where() form, and fabd9cd restored it. The tree of fabd9cd equals 3e65085, so the text is the one reviewed then. Looking at it again, the custom-selector advice leads to the pressed-state regression that #11010 and #11025 now have. Tested merged with main at ecaa2f5.
Must fix
- The custom-selector advice hides the pressed style.
for-styling.mdx:114says to usehtml:not([data-whatintent='touch'], [data-whatintent='keyboard']) &:hoverfor custom selectors. That prefix adds 0,1,1 to the selector. A typical&:activerule after it then loses, so while the mouse button is down the element keeps its hover look. The:not(:active)bullet only speaks about the mixin and says "when needed", so a reader who follows this paragraph does not see that it is needed here.
I tested it in a page inside.eufemia-scope--portal, with a hover rule and a later:activerule. In Chromium, Firefox and WebKit, the pressed color wins with a plain:hover. With the documented guard, the hover color wins while the button is down. With the documented guard plus:not(:active), the pressed color wins again. The same pattern breaks the pressed look on 79 of 81 Chips (#11010) and 27 of 27 MultiSelection rows (#11025) in Chromium.
Suggested fix: say that the guard raises specificity, and add:not(:active)to the documented selector:html:not([data-whatintent='touch'], [data-whatintent='keyboard']) &:hover:not(:active). A zero-specificity form that works with style scoping is&:hover:where(html:not([data-whatintent='touch'], [data-whatintent='keyboard']) *). The:where(html...) &form in866f395never matched in scoped builds, as1d709d1on #11010 notes.
Suggestions (non-blocking)
- Merge after #11053. On
main,utilities.hover()ishtml:not([data-whatintent='touch']) &:hover, with noany-hoverquery and nokeyboardcheck. So "shows hover styles only on devices with a pointer that can hover, and not while the current input is touch or keyboard" is true only with #11053. - The design tokens guide still shows unguarded
&:hoverin its examples (design-tokens/guide.mdx:97and:162, anddesign-tokens/info.mdx:53). Readers who copy them get the sticky hover. A link to#hover-styleswould help. This can be a follow-up. - "A tap hides hover styles" has one exception. The input helper treats a
mousedownas touch only within 200 ms of the touch. In Chromium with touch emulation, a tap held for 350 ms setdata-whatintent="mouse". On a device with a touchscreen and a mouse or trackpad, a slow tap can then bring the hover back. True but rare; the fix belongs in the helper, not in this text.
What I checked
git diff 3e65085 fabd9cdis empty. Real trial merge withmainecaa2f5: no conflicts. Prettier passes on the file.- Each statement against the source on #11053 (
29f8a22, the live head): the mixin wraps the rule in@media (any-hover: hover)and checkshtml:not([data-whatintent='touch'], [data-whatintent='keyboard']). Before the tracking starts there is no attribute, so the media query alone decides.whatInput.tskeeps the intent when a key is pressed in aninput,selectortextarea. Button usesutilities.hover()onmain. - The
hoverandany-hoverclaims: an iPad with a trackpad reportshover: noneandany-hover: hover(see the Tailwind CSS issue #11109). I could not test real hardware. - The SCSS example compiles with the #11053 mixin. The hover rule ends in
:not([disabled]):not(:active), so the pressed style fromutilities.active()wins. - The focus-style bullet matches the #11025 rule
html:not([data-whatintent='mouse'])[data-whatinput='keyboard'] &:not(:active):has(...). With touch emulation, a tapped row shows its focus frame again after Tab and Shift+Tab, in all three engines. - The branch preview (
pr-11027) renders the section with the restored paragraph. The PR changes no library code, so thedocstype fits.
CI on fabd9cd2cf: all 23 checks passed. Rechecked just before posting: the head is still fabd9cd, and it merges into main at ecaa2f5 without conflicts.
Motivation: https://dnb-it.slack.com/archives/CMXABCHEY/p1795427065802309
Touch browsers can keep hover styles after a tap, making controls look checked or selected. Explain how to use the shared hover mixin and current input tracking, while keeping pressed and keyboard focus feedback.
A hover media query describes pointer capability and can stay true during touchscreen use on a laptop. The guide explains why it does not replace input tracking when the user switches between touch, keyboard and mouse.
Use together with #11053 for the shared hover behavior.