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

fix: improve a11y on some components #1045

Merged
merged 19 commits into from
Nov 8, 2023
Merged

fix: improve a11y on some components #1045

merged 19 commits into from
Nov 8, 2023

Conversation

KirillDyachkovskiy
Copy link
Contributor

UXRFC-202

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

);
} 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"
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

argeed

Copy link
Contributor

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 */}
Copy link
Contributor

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 {
Copy link
Contributor

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}
Copy link
Contributor

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

<div
ref={ref}
onClick={hasOnClick ? onClick : undefined}
role={hasOnClick ? 'role' : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

role="button"?

@@ -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(
Copy link
Contributor

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?

@@ -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)
Copy link
Contributor

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

&:not(#{$disabled})#{$block}_is-interactive:focus:not(
:has(#{$block}__addon_interactive:focus)
) {
box-shadow: 0 0 0 2px var(--g-color-line-focus);
Copy link
Contributor

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 || (
Copy link
Contributor

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 */}
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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

@KirillDyachkovskiy KirillDyachkovskiy merged commit c6c6138 into main Nov 8, 2023
3 checks passed
@KirillDyachkovskiy KirillDyachkovskiy deleted the check-a11y branch November 8, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.