Skip to content

Conversation

marissahuysentruyt
Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt commented Jun 9, 2025

Description

This work builds off of the spectrum-two fix for this in adobe/spectrum-css#3767, but addressing the same bug in the S1 context for SWC components. The switch in either context should now respond appropriately to the active state, with the active styles taking precedence over any hover styles. When a user now activates the active/down state, a visual difference can be noted, and that visual difference is no longer dependent on mouse movement (where it was incorrect before).

New behavior

Screen.Recording.2025-06-10.at.9.51.52.AM.mov

Motivation and context

It was brought up in a Slack bug report that the switch may have some specificity issues between the hover and active states. The original message noted how to reproduce what they were seeing:

Note the default color of the switch
Hover on the switch, note the color change
Click and hold on the switch, note there is no color change
While holding the mouse down, move the mouse off the switch -- note the color is now darker than default or hover
Release the mouse with your cursor outside of the switch and the color goes back to default

Production (old behavior)

Screen.Recording.2025-06-10.at.9.48.11.AM.mov

Related issue(s)

  • CSS-1240 (clones 👇 1199)
  • CSS-1199 (archived)

Screenshots (if appropriate)


Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have included a well-written changeset if my change needs to be published.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • [n/a] Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

S1

  • Unchecked switch down state styles

    1. Go to the switch default story
    2. Using the steps noted in the "Motivation and context" section above, you should be able to visually see the active/down state styles get triggered on click, as opposed to not seeing the down state styles until after you have clicked AND dragged off of the switch.
    3. Inspect sp-switch and toggle :active and :hover states in your browser tools.
    4. Verify that the border-color for the #switch::before element renders --spectrum-switch-handle-border-color-down [@cdransf]
  • Checked switch down state styles

    1. Go to the checked switch story
    2. Once again, using the steps noted in the "Motivation and context" section above, you should be able to visually see the active/down state styles get triggered on click, as opposed to not seeing the down state styles until after you have clicked AND dragged off of the switch.
    3. Inspect sp-switch and toggle :active and :hover states in your browser tools.
    4. Verify that the border-color for the #switch::before element renders --spectrum-switch-handle-border-color-selected-down. [@cdransf]

Additional validation

  • Test the same steps as outlined in the "Motivation and context" section on the 2 emphasized stories. Results should be the same, just with emphasized styles. [@cdransf]
  • Test the read-only and disabled switches. When going through the steps outlined, nothing should occur (this was the behavior as it was before these changes). [@cdransf]

S2 foundations & Express

  • Repeat the test scenarios above in the S2 foundations and Express context. [@cdransf]

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Copy link

changeset-bot bot commented Jun 9, 2025

🦋 Changeset detected

Latest commit: bca581c

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

This PR includes changesets to release 84 packages
Name Type
@spectrum-web-components/switch Patch
@spectrum-web-components/story-decorator Patch
@spectrum-web-components/bundle Patch
@spectrum-web-components/custom-vars-viewer Patch
documentation Patch
@spectrum-web-components/eslint-plugin Patch
@spectrum-web-components/accordion Patch
@spectrum-web-components/action-bar Patch
@spectrum-web-components/action-button Patch
@spectrum-web-components/action-group Patch
@spectrum-web-components/action-menu Patch
@spectrum-web-components/alert-banner Patch
@spectrum-web-components/alert-dialog Patch
@spectrum-web-components/asset Patch
@spectrum-web-components/avatar Patch
@spectrum-web-components/badge Patch
@spectrum-web-components/breadcrumbs Patch
@spectrum-web-components/button-group Patch
@spectrum-web-components/button Patch
@spectrum-web-components/card Patch
@spectrum-web-components/checkbox Patch
@spectrum-web-components/clear-button Patch
@spectrum-web-components/close-button Patch
@spectrum-web-components/coachmark Patch
@spectrum-web-components/color-area Patch
@spectrum-web-components/color-field Patch
@spectrum-web-components/color-handle Patch
@spectrum-web-components/color-loupe Patch
@spectrum-web-components/color-slider Patch
@spectrum-web-components/color-wheel Patch
@spectrum-web-components/combobox Patch
@spectrum-web-components/contextual-help Patch
@spectrum-web-components/dialog Patch
@spectrum-web-components/divider Patch
@spectrum-web-components/dropzone Patch
@spectrum-web-components/field-group Patch
@spectrum-web-components/field-label Patch
@spectrum-web-components/help-text Patch
@spectrum-web-components/icon Patch
@spectrum-web-components/icons-ui Patch
@spectrum-web-components/icons-workflow Patch
@spectrum-web-components/icons Patch
@spectrum-web-components/iconset Patch
@spectrum-web-components/illustrated-message Patch
@spectrum-web-components/infield-button Patch
@spectrum-web-components/link Patch
@spectrum-web-components/menu Patch
@spectrum-web-components/meter Patch
@spectrum-web-components/modal Patch
@spectrum-web-components/number-field Patch
@spectrum-web-components/overlay Patch
@spectrum-web-components/picker-button Patch
@spectrum-web-components/picker Patch
@spectrum-web-components/popover Patch
@spectrum-web-components/progress-bar Patch
@spectrum-web-components/progress-circle Patch
@spectrum-web-components/radio Patch
@spectrum-web-components/search Patch
@spectrum-web-components/sidenav Patch
@spectrum-web-components/slider Patch
@spectrum-web-components/split-view Patch
@spectrum-web-components/status-light Patch
@spectrum-web-components/swatch Patch
@spectrum-web-components/table Patch
@spectrum-web-components/tabs Patch
@spectrum-web-components/tags Patch
@spectrum-web-components/textfield Patch
@spectrum-web-components/thumbnail Patch
@spectrum-web-components/toast Patch
@spectrum-web-components/tooltip Patch
@spectrum-web-components/top-nav Patch
@spectrum-web-components/tray Patch
@spectrum-web-components/underlay Patch
@spectrum-web-components/vrt-compare Patch
@spectrum-web-components/base Patch
@spectrum-web-components/grid Patch
@spectrum-web-components/opacity-checkerboard Patch
@spectrum-web-components/reactive-controllers Patch
@spectrum-web-components/shared Patch
@spectrum-web-components/styles Patch
@spectrum-web-components/theme Patch
@spectrum-web-components/truncated Patch
example-project-rollup Patch
example-project-webpack 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

github-actions bot commented Jun 9, 2025

Branch preview

Review the following VRT differences

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link
Contributor

github-actions bot commented Jun 9, 2025

Tachometer results

Chrome

switch permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 446 kB 15.39ms - 15.83ms - faster ✔
4% - 8%
0.59ms - 1.28ms
branch 425 kB 16.28ms - 16.81ms slower ❌
4% - 8%
0.59ms - 1.28ms
-
Firefox

switch permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 446 kB 34.42ms - 36.50ms - faster ✔
1% - 9%
0.25ms - 3.55ms
branch 425 kB 36.07ms - 38.65ms slower ❌
1% - 10%
0.25ms - 3.55ms
-

@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-1240-switch-down-state-s1 branch from 36dda22 to 293e961 Compare June 10, 2025 13:02
@marissahuysentruyt marissahuysentruyt marked this pull request as ready for review June 10, 2025 16:17
@marissahuysentruyt marissahuysentruyt requested a review from a team as a code owner June 10, 2025 16:17
@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-1240-switch-down-state-s1 branch 2 times, most recently from ae3b0ce to 4ba214b Compare June 10, 2025 17:27
Copy link
Member

@cdransf cdransf left a comment

Choose a reason for hiding this comment

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

Ran through validation steps and everything looks good! ✨

@castastrophe castastrophe force-pushed the marissahuysentruyt/css-1240-switch-down-state-s1 branch 2 times, most recently from ceaa466 to 95e2b8c Compare June 11, 2025 15:22
@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-1240-switch-down-state-s1 branch from 95e2b8c to a5155e9 Compare June 11, 2025 18:24
@castastrophe castastrophe force-pushed the marissahuysentruyt/css-1240-switch-down-state-s1 branch from a5155e9 to b89f32f Compare June 12, 2025 15:04
@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-1240-switch-down-state-s1 branch from b89f32f to 856fdb4 Compare June 12, 2025 17:22
- corrects the active state colors for the handle and background, so it
doesn't change if a user hovers or moves their mouse while still
activating the switch.
- ensure readonly switches don't show active state
- add missing highcontrast variables
- create changeset
@marissahuysentruyt marissahuysentruyt force-pushed the marissahuysentruyt/css-1240-switch-down-state-s1 branch from 856fdb4 to bca581c Compare June 13, 2025 13:45
@marissahuysentruyt marissahuysentruyt added ready-for-merge Will auto-update until merged and removed ready-for-review labels Jun 13, 2025
@caseyisonit caseyisonit merged commit dcd2cd3 into main Jun 13, 2025
23 checks passed
@caseyisonit caseyisonit deleted the marissahuysentruyt/css-1240-switch-down-state-s1 branch June 13, 2025 15:23
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.

4 participants