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

Incorrect use of aria-hidden with LabIcon in launcher #16167

Open
krassowski opened this issue Apr 15, 2024 · 1 comment
Open

Incorrect use of aria-hidden with LabIcon in launcher #16167

krassowski opened this issue Apr 15, 2024 · 1 comment

Comments

@krassowski
Copy link
Member

Description

The notebook/console/other icons in Launcher sections have aria-hidden defined in:

<div className="jp-Launcher-section" key={cat}>
<div className="jp-Launcher-sectionHeader">
<LabIcon.resolveReact
icon={icon}
iconClass={classes(iconClass, 'jp-Icon-cover')}
stylesheet="launcherSection"
aria-hidden="true"
/>
<h2 className="jp-Launcher-sectionTitle">{cat}</h2>
</div>

But this is incorrect and does not achieve the intended result because these attributes are passed to style, not the node:

Reproduce

image

Expected behavior

aria-hidden is defined in a such a way that it is set on the HTML node.

Context

  • JupyterLab version: 4.2.0a1

The aria-hidden was introduced in #15265 (CC @j264415)

@krassowski krassowski added bug tag:Accessibility status:Needs Triage Applied to new issues that need triage labels Apr 15, 2024
@krassowski
Copy link
Member Author

krassowski commented Apr 16, 2024

If we want to allow passing aria-hidden, we should explicitly unpack these from props here:

const {
className,
container,
label,
title,
tag = 'div',
...styleProps
}: LabIcon.IProps = { ...this._props, ...props };
// set up component state via useState hook
const [, setId] = React.useState(this._uuid);
// subscribe to svg replacement via useEffect hook
React.useEffect(() => {
const onSvgReplaced = () => {
setId(this._uuid);
};
this._svgReplaced.connect(onSvgReplaced);
// specify cleanup callback as hook return
return () => {
this._svgReplaced.disconnect(onSvgReplaced);
};
});
// make it so that tag can be used as a jsx component
const Tag = tag ?? React.Fragment;
// ensure that svg html is valid
if (!(this.svgInnerHTML && this.svgReactAttrs)) {
// bail if failing silently
return <></>;
}
const svgComponent = (
<svg
{...this.svgReactAttrs}
dangerouslySetInnerHTML={{ __html: this.svgInnerHTML }}
ref={ref}
/>
);
if (container) {
Private.initContainer({ container, className, styleProps, title });

as currently everything other than className, container, label, title and tag goes to styleProps. We should also add proper typing typing for it. Currently these props inherit from typestyle's NestedCSSProperties:

export interface IProps extends NestedCSSProperties, ISheetOptions {

import { NestedCSSProperties } from 'typestyle/lib/types';

which ironically does not check if the keys are valid style keys, it just defines them as string, also see typestyle/typestyle#276.

Maybe we should deprecate LabIcon.resolveReact and add a new version of this method which would only allow valid HTML attributes, and would not pass styles at all (so that we can remove typestyle dependency in the future altogether).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants