-
Notifications
You must be signed in to change notification settings - Fork 3
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
keyboard navigation: feature/focus states #589
Conversation
… into feature/focus-states
//Dropdown | ||
@dropdown-menu-bg: @dark-four; | ||
@dropdown-vertical-padding: 5px; | ||
@dropdown-edge-child-vertical-padding: 4px; | ||
@dropdown-font-size: @font-size-base; | ||
@dropdown-line-height: 22px; | ||
|
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.
Continuing to pivot away from .less
in anticipation of migrating to antd 5
Coverage report
Test suite run success121 tests passing in 7 suites. Report generated by 🧪jest coverage report action from c2ac2a0 |
.nav-button.dropdown-item-button:global(.ant-btn) { | ||
background-color: inherit; | ||
border: inherit; |
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.
In some cases we were using <a>
to open modals but for accessibility those should be a buttons, even if its easier to style when they are all the same element type. I also felt the styling for all the differenet elements that can be dropdown menu items should be in the CustomDropdown
stylesheet.
Using <NavButton />
, making the new DropdownItem
button class, and using these two inherit rules seemed to be the most concise way to manage selector specificity and keep the styling where I wanted it. Open to suggestions.
… into feature/focus-states
… into feature/focus-states
const CustomDropdown: React.FC<CustomDropdownProps> = ({ | ||
items, | ||
titleText, | ||
icon, | ||
buttonType, | ||
placement, | ||
disabled, | ||
narrow, | ||
}) => { | ||
const menuClassNames = narrow | ||
? classNames(styles.menu, styles.narrow) | ||
: styles.menu; | ||
return ( | ||
<Dropdown | ||
menu={{ items, theme: "dark", className: menuClassNames }} | ||
placement={placement} | ||
disabled={disabled} | ||
> | ||
<NavButton | ||
titleText={titleText} | ||
icon={icon} | ||
buttonType={buttonType} | ||
/> | ||
</Dropdown> | ||
); | ||
}; |
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.
Like our CustomModal
and NavButton
this wrapper is mostly to DRY out the code, and will be a vehicle for code for things that antd
doesn't provide but can be generalized to all dropdowns.
.menu.narrow { | ||
width: calc(var(--dropdown-menu-width) - 50px); | ||
} |
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.
This file replaces the now deleted stylesheets for HelpMenu
and LoadFileMenu
.
This was the only style difference between the two to manage for now.
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.
Taking for granted that everything works, I see no obvious code smells. LGTM!
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.
Left some non-blocking comments but love the accessibility changes.
src/components/HelpMenu/index.tsx
Outdated
</Dropdown> | ||
<CustomDropdown | ||
items={items} | ||
titleText={"Help "} |
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.
Should CustomDropdown
/NavButton
just add spacing between the titleText and the icon?
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.
Why don't we just remove that silly space instead.
} | ||
|
||
.menu.narrow { | ||
width: calc(var(--dropdown-menu-width) - 50px); |
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.
Nit: This seems a little magic number-y, would it make more sense to either define a narrow width variable or make the width set by fit-content
or something?
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.
Much better, thank you
<Dropdown | ||
menu={{ items, theme: "dark", className: styles.menu }} | ||
<CustomDropdown | ||
items={items} | ||
titleText={"Load model"} | ||
icon={DownArrow} | ||
buttonType={ButtonClass.Primary} | ||
placement="bottomRight" | ||
disabled={isDisabled} | ||
> | ||
<NavButton | ||
titleText={"Load model"} | ||
icon={DownArrow} | ||
buttonType={ButtonClass.Primary} | ||
isDisabled={isDisabled} | ||
/> | ||
</Dropdown> |
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.
Really like that the NavButton gets collapsed into Dropdown in all the instances here :')
@@ -117,18 +117,14 @@ const LoadFileMenu = ({ | |||
|
|||
return ( | |||
<> | |||
<Dropdown | |||
menu={{ items, theme: "dark", className: styles.menu }} |
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.
Do we lose the dark theming here on the dropdown?
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.
No we don't, although we are overriding most of it anyway.
src/components/NavButton/style.css
Outdated
color: var(--dark-theme-action-button-hover-color); | ||
} | ||
|
||
.nav-button.action-button:global(.ant-btn:focus) { |
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.
Consider changing the focus
selectors to focus-visible
, which will make it only respond to keyboard focusing (and not if the user last clicked on the button)
https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible
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.
Thank you!
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.
FYI: I updated the lines relevant to this PR , but not every place that :focus
exists in the code base although I have that in mind now for this ongoing work.
Time estimate or Size
medium/small
Problem
Closes #575 and #576, advances #347
Part of keyboard navigation and accessibility work.
Solution
Focus styling for action buttons has been reviewed with Lyndsay but is not reflected in master Figma yet.
Styling for primary/secondary buttons, and dropdown elements is there.
Style guide
Closing #576 because they already work, its clear how to tab through them now that the visual style is obivous.
Disabled buttons are taking focus/styling for now, this can be discussed more in future as we get into navigation behavior.
CustomDropdown
Wrapper for our Dropdowns, unifies the stylesheets, just a slight DRYing now, but will be very useful going forward.
Steps to Verify:
Applying focus styling to ALL interactive elements is out of scope for this PR (e.g. submenu items in drop-downs)
Screenshots (optional):