-
Notifications
You must be signed in to change notification settings - Fork 99
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: improve a11y on some components #1045
Conversation
Preview is ready. |
src/components/Link/Link.tsx
Outdated
); | ||
} else { | ||
return ( | ||
<span | ||
{...(extraProps as React.HTMLAttributes<HTMLSpanElement>)} | ||
{...commonProps} | ||
ref={ref as React.Ref<HTMLSpanElement>} | ||
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex | ||
role="link" |
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'm not sure that it is true
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.
argeed
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.
And I think we should remove this behaviour in the next major (#600)
@@ -201,6 +201,7 @@ export const TableColumnSetup = (props: TableColumnSetupProps) => { | |||
|
|||
return ( | |||
<div className={b(null, className)}> | |||
{/* It is used to handle clicks on the switcher control */} |
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.
that should not work this way
we should pass handler via some context i guess to easily pass it to rendered component
@@ -14,6 +14,16 @@ $block: '.#{variables.$ns}user-avatar'; | |||
background-position: center; | |||
background-size: cover; | |||
|
|||
outline: none; | |||
|
|||
&: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.
we probably have SCSS mixin for it
onKeyDown={onKeyDown} | ||
className={b({size}, className)} | ||
title={title} | ||
onClick={onClick} |
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.
onClick supposed to be removed from this component
src/components/Label/Label.tsx
Outdated
<div | ||
ref={ref} | ||
onClick={hasOnClick ? onClick : undefined} | ||
role={hasOnClick ? 'role' : undefined} |
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.
role="button"?
src/components/Label/Label.scss
Outdated
@@ -14,6 +14,20 @@ $transitionTimingFunction: ease-in-out; | |||
border: var(--border-size) solid #{$borderColor}; | |||
} | |||
|
|||
// focus on interactive label (excluding focus on addon) | |||
&:not(#{$disabled})#{$block}_is-interactive:focus: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.
What about not setting is-interactive flag if disabled is true?
src/components/Label/Label.scss
Outdated
@@ -14,6 +14,20 @@ $transitionTimingFunction: ease-in-out; | |||
border: var(--border-size) solid #{$borderColor}; | |||
} | |||
|
|||
// focus on interactive label (excluding focus on addon) | |||
&:not(#{$disabled})#{$block}_is-interactive:focus:not( | |||
:has(#{$block}__addon_interactive: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.
If Label is clickable and has close button this wouldn't allow to focus the Label itself
src/components/Label/Label.scss
Outdated
&:not(#{$disabled})#{$block}_is-interactive:focus:not( | ||
:has(#{$block}__addon_interactive:focus) | ||
) { | ||
box-shadow: 0 0 0 2px var(--g-color-line-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.
Let's use outline here
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */} | ||
<div className={b('control')} ref={refControl} onClick={handleControlClick}> | ||
{switcher || ( | ||
{renderSwitcher?.({onClick: handleControlClick}) || switcher || ( |
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.
We should create onKeyDown via useActionHandlers
and pass it along with the onClick
return ( | ||
<DropdownMenuContext.Provider value={contextValue}> | ||
{/*as this div has Button component as child, clicking on it one fires onClick of this div on bubbling*/} | ||
{/* FIXME remove switcher prop and this wrapper */} |
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 is this planned to be done?
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.
After a major library update
/** | ||
* Menu toggle control. | ||
*/ | ||
renderSwitcher?: (props: SwitcherProps) => React.ReactNode; |
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 we need this prop? We can keep current api, but use cloneElement to add handlers to switcher
UXRFC-202