-
Notifications
You must be signed in to change notification settings - Fork 196
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
fix(rating): address inconsistent hover behavior #3196
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 1ed0669 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
🚀 Deployed on https://pr-3196--spectrum-css.netlify.app |
File metricsSummaryTotal size: 4.27 MB* Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.
Detailsrating
* Results are not gzipped or minified. * An ASCII character in UTF-8 is 8 bits or 1 byte. |
3a4f7ca
to
878ed6c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing, I'm seeing a couple issues:
-
The focus ring should not be appearing on click. The existing
is-focused
is actually just for keyboard focus.Really
.is-focused
should be named.is-keyboardFocused
or even better the selector could be&:has(:focus-visible), &.is-keyboardFocused { ... }
, though I'm not sure we want to do that sort of renaming now? If we're already doing a breaking change, we could, though I'm hesitant to increase the scope of this work.I'd definitely reword the docs sentence that says "When the rating receives focus" to "When the rating receives keyboard focus".
-
Clicking on any of the ratings on the Docs page doesn't update something with the current value; the underline will show in the wrong place.
-
The
is-hovered
class gets leftover on elements when Rating is no longer being hovered
components/rating/index.css
Outdated
@@ -168,6 +157,16 @@ | |||
display: block; | |||
} | |||
} | |||
|
|||
&.is-hovered { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirement for this class and how it should be used needs to be included in usage notes within the documentation. Within the PR description would be helpful as well.
As I am understanding it, previously CSS would set all stars filled on hover of the whole component, and then all stars following the hovered star unfilled using the subsequent-sibling combinator (~
). And that will not work when you hover on the gap between items. And with this change you are looking at having a class that the implementation will apply to the hovered star as well as all previous stars? And those classes should stay until hover or focus leaves the component?
I think that could work. Perhaps this class should be something like .is-hoverSelection
? It seems odd to also have is-hovered
on elements that aren't actually hovered. It might also be worth adding the hover pseudo to the selector :hover, &.is-hoverSelection
.
Another option would be using padding instead of gaps, but I don't know if we want to go that route or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! I'll add this to the PR description and will look for the usage notes.
That is an accurate description of the issue — I first approached it using CSS but there's an issue with one of our postcss plugins when trying to style one of the stars based on the hover state of the next: saulhardman/postcss-hover-media-feature#35.
I've updated the selector to use :hover, .is-hoverSelection
. The latter is now removed from all child icons on mouseout
of the parent component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated is-focused
to be is-keyboardFocused
and changed the state in the stories and templates too.
Clicking on any of the ratings on the Docs page doesn't update something with the current value; the underline will show in the wrong place.
I need to look at this a bit more — it doesn't look like the instance in the docs is making it into the @change
handler that updates this (as it works in the stories for the component):
@change=${function(e) {
const rating = e.target.closest(`.${rootClass}`);
if (!rating) return;
const input = rating.closest(`.${rootClass}-input`);
if (!input) return;
if (!isReadOnly && !isDisabled) {
updateArgs({ value: parseInt(input.value, 10) });
}
}}
8470a26
to
610396a
Compare
6147f91
to
f0255e7
Compare
01f2393
to
634d93d
Compare
10a21fa
to
f3e2a45
Compare
Marking this as |
4b70482
to
82cbeeb
Compare
77bf122
to
9b2e186
Compare
7bd952c
to
6399ea5
Compare
6399ea5
to
65707f1
Compare
Bumps [eslint-plugin-jsonc](https://github.com/ota-meshi/eslint-plugin-jsonc) from 2.16.0 to 2.18.2. - [Release notes](https://github.com/ota-meshi/eslint-plugin-jsonc/releases) - [Changelog](https://github.com/ota-meshi/eslint-plugin-jsonc/blob/master/CHANGELOG.md) - [Commits](ota-meshi/eslint-plugin-jsonc@v2.16.0...v2.18.2) --- updated-dependencies: - dependency-name: eslint-plugin-jsonc dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marissa Huysentruyt <[email protected]>
Co-authored-by: Marissa Huysentruyt <[email protected]>
65707f1
to
1ed0669
Compare
Description
Provides more granular control over the hover behavior of child stars within the rating component to prevent hovering in space adjacent to the component from highlighting all stars.
CSS-735
How and where has this been tested?
Verified in local Storybook story for rating component.
Validation steps
Regression testing
Validate:
Screenshots
To-do list