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

refactor(components): menu item only changes color on focus-visible #2327

Merged
merged 7 commits into from
Jan 22, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/components/src/Menu/Menu.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,26 @@

.action {
display: flex;
gap: var(--menu-space);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

width: 100%;
padding: var(--menu-space);
border: none;
border-radius: var(--radius-base);
outline: transparent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Beacuse we're using box-shadow on focus, this sets outline to transparent so that high-contrast modes still work.

text-align: start;
background-color: transparent;
cursor: pointer;
gap: var(--menu-space);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This re-order happened via auto-fix

align-items: center;
transition: background-color var(--timing-base) ease-in;
chris-at-jobber marked this conversation as resolved.
Show resolved Hide resolved
}

.action:hover,
.action:focus {
.action:focus-visible {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

focus-visible respects browser heuristics for what should and not be focused

background-color: var(--color-surface--hover);
}

.action:focus-visible {
outline-color: var(--color-focus);
box-shadow: var(--shadow-focus);
}
.action span {
/* match appearance of Button labels */
Expand Down
Loading