Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ActionList] Add hover to aria-current elements and other micro interactions #1870

Merged
merged 7 commits into from
Jan 12, 2022

Conversation

vdepizzol
Copy link
Contributor

@vdepizzol vdepizzol commented Jan 7, 2022

This PR started as a quick fix for https://github.com/github/github/discussions/201185#discussioncomment-1907903 (private for hubbers), but I've also touched a couple of other related micro interactions:

  • Add hover background for selected item (fixes https://github.com/github/github/discussions/201185#discussioncomment-1907903)

  • Makes -webkit-tap-highlight-color transparent — this removes a blueish highlight background on touch devices. It was particularly problematic on items with subGroup elements. Since :active states remain available on touch, users should see the regular gray background instead.

    Preview
  • Add touch-action: manipulation. This should speed up the tap response on touch devices. From MDN:

    Enable panning and pinch zoom gestures, but disable additional non-standard gestures such as double-tap to zoom. Disabling double-tap to zoom removes the need for browsers to delay the generation of click events when the user taps the screen. This is an alias for "pan-x pan-y pinch-zoom" (which, for compatibility, is itself still valid).

  • Wrap :hover styles around @media (hover: hover) { } media queries, to avoid sticky hovers on touch.

  • Add "slide down" animation when expanding subGroup. This should hopefully improve the parsing when interacting with longer lists, and compensate the user expectation since we're no longer redirecting to the first sub-item right away.

    slideDown-subGroup.mov
  • Disable max-nesting-depth and selector-max-specificity stylelint rules in the file level, as, per design, the component requires more nuanced CSS selectors throughout.

Are additional changes needed?

  • No, this PR should be ok to ship as is. 🚢

Also included a quick transition for subGroup elements
Also:
- Avoided sticky hover on touch devices with hover:hover media query
- removed pointer: fine specificity to hover media queries
- simplified reduce-motion media query
@vdepizzol vdepizzol requested a review from a team as a code owner January 7, 2022 01:24
@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2022

🦋 Changeset detected

Latest commit: cca1f62

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/css Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@simurai simurai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of nice touches. That slide down looks nice. 😍

&:hover {
cursor: pointer;
background-color: var(--color-action-list-item-default-hover-bg);
@media (hover: hover) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this recently, but a while back using @media (hover: hover) was not really reliable for "hybrid devices" (like a laptop with a touch screen, or connecting a mouse to an iPad). The @media (hover: hover) would only work for what the browser thought is the "primary" input but would not adjust when switching touch/mouse on the fly. Maybe that improved by now and it is a bit of an edge case, so maybe still fine to keep it until we hear some reports about it. 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simurai that's a great point! I think this is still an expected behavior for hybrid devices, according to the latest W3C Media Query specs.

Example 44
For example, on a touch screen device that can also be controlled by an optional mouse, the hover media feature should match hover: none, as the primary pointing device (the touch screen) does not allow the user to hover.
However, despite this, the optional mouse does allow users to hover. Authors should therefore be careful not to assume that the ':hover' pseudo class will never match on a device where 'hover:none' is true, but they should design layouts that do not depend on hovering to be fully usable.

I think the current solution is a good compromise. Showing or not showing a hover state (in case of a laptop with touch screen, or a touch device with a plugged-in mouse, respectively) is not an unexpected behavior for these non-primary types of interactions, I'd say.

👍

Copy link
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍🏻

@@ -300,11 +335,10 @@
color: var(--color-danger-fg);
}

@media (hover: hover) and (pointer: fine) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you remove and (pointer: fine) because we weren't getting hover styles on touch devices with an optional mouse?

Copy link
Contributor Author

@vdepizzol vdepizzol Jan 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mperrotti no... I removed it because the pointer query shouldn't influence whether we display these :hover styles or not. Devices that have pointer: coarse which also support hover: hover should still display it. See the combination table from W3C for reference.

✌️

@@ -154,11 +183,14 @@
}

.ActionList--subGroup {
display: block;
height: auto;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants