-
Notifications
You must be signed in to change notification settings - Fork 889
Refactoring EuiKeyPadMenuItem beta badge for improved accessibility
#5508
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
Changes from 2 commits
3258086
c107d41
8723f28
1f09ad2
6f679f3
3744698
ba06212
a7d44b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,10 +92,6 @@ | |
| .euiKeyPadMenuItem__checkableInput { | ||
| transform: scale(.75); | ||
| transform-origin: top right; | ||
| } | ||
|
|
||
| .euiKeyPadMenuItem__checkableInput, | ||
| .euiKeyPadMenuItem__betaBadge { | ||
| position: absolute; | ||
| top: $euiSizeXS; | ||
| right: $euiSizeXS; | ||
|
|
@@ -126,3 +122,12 @@ | |
| border-color: $euiColorPrimaryText; | ||
| } | ||
| } | ||
|
|
||
| .euiKeyPadMenuListItem { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this out as a top-level element in the SCSS to ensure consistent absolute positioning and lessening risk of the cascade modifying something.
1Copenut marked this conversation as resolved.
Outdated
|
||
| .euiToolTipAnchor { | ||
| position: absolute; | ||
| top: $euiSizeS; | ||
| right: $euiSizeS; | ||
| z-index: 3; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -225,6 +225,7 @@ export const EuiKeyPadMenuItem: FunctionComponent<EuiKeyPadMenuItemProps> = ({ | |||||
|
|
||||||
| return ( | ||||||
| <EuiBetaBadge | ||||||
| aria-label={`${label}. Beta item.`} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any hard coded text should use the useEuiI18n utility to allow localization.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cchaos does this labelling match the intent of specifying an
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My guess is that we should actually be labelling @1Copenut I think we need to re-think this solution. Mainly, one of the issues I'm seeing is that if a consumer were to use Would it be a better solution to revert back the styling to include the beta badge within the button, but
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you @cchaos for this use case my solution hadn't anticipated. I talked about this with Chandler in our 1:1 yesterday. Refactored it to add a relatively positioned DIV. I couldn't keep the beta badge nested inside the button because the axe plugin was complaining about a nested element, and hiding it with Moving the beta badge out to a sibling of the button felt like the best approach to balance all concerns. |
||||||
| size="s" | ||||||
| color="subdued" | ||||||
| className="euiKeyPadMenuItem__betaBadge" | ||||||
|
|
@@ -238,7 +239,7 @@ export const EuiKeyPadMenuItem: FunctionComponent<EuiKeyPadMenuItemProps> = ({ | |||||
|
|
||||||
| const renderContent = () => ( | ||||||
| <span className="euiKeyPadMenuItem__inner"> | ||||||
| {checkable ? renderCheckableElement() : renderBetaBadge()} | ||||||
| {checkable && renderCheckableElement()} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| <span className="euiKeyPadMenuItem__icon">{children}</span> | ||||||
| <span className="euiKeyPadMenuItem__label">{label}</span> | ||||||
| </span> | ||||||
|
|
@@ -269,14 +270,17 @@ export const EuiKeyPadMenuItem: FunctionComponent<EuiKeyPadMenuItemProps> = ({ | |||||
| } | ||||||
|
|
||||||
| return ( | ||||||
| <Element | ||||||
| className={classes} | ||||||
| {...(relObj as ElementType)} | ||||||
| {...(rest as ElementType)} | ||||||
| // Unable to get past `LegacyRef` conflicts | ||||||
| ref={buttonRef as Ref<any>} | ||||||
| > | ||||||
| {renderContent()} | ||||||
| </Element> | ||||||
| <React.Fragment> | ||||||
| <Element | ||||||
| className={classes} | ||||||
| {...(relObj as ElementType)} | ||||||
| {...(rest as ElementType)} | ||||||
| // Unable to get past `LegacyRef` conflicts | ||||||
| ref={buttonRef as Ref<any>} | ||||||
| > | ||||||
| {renderContent()} | ||||||
| </Element> | ||||||
| {betaBadgeLabel && renderBetaBadge()} | ||||||
|
chandlerprall marked this conversation as resolved.
Outdated
|
||||||
| </React.Fragment> | ||||||
| ); | ||||||
| }; | ||||||
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 added this
role="button"because Safari + VoiceOver wasn't consistently announcing the tooltip. Found this article Short note on aria-label, aria-labelledby, and aria-describedby by Leonie Watson that gave me a clue the span alone might not honor our ARIA markup consistently.