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

feat(accessible-names): require accessible names in non-text wrapping components #732

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

nataliadelmar
Copy link
Collaborator

@nataliadelmar nataliadelmar commented Dec 12, 2024

Adding type requirement or console.warning to components that need an accessible name:

Required type:

  • <AriaToolbar /> SPARK-583000
  • <List /> SPARK-582998
  • <NavigationTab />
  • <Reaction />
  • <Slider />
  • <Tree /> SPARK-582999
  • <ToastNotification /> (require close button label)

Console.warn (just because they could trigger a Tooltip type="label"):

  • <AddReactionButton /> SPARK-582980
  • <ButtonCircle /> SPARK-582980
  • <ButtonCircleLink /> SPARK-582980
  • <ButtonCircleToggle /> SPARK-582980
  • <ReactionBadge /> SPARK-582980
  • <ReactionButton /> SPARK-582980


const AddReactionButton = forwardRef((props: Props, ref: ForwardedRef<HTMLButtonElement>) => {
const { className, id, style, ...otherProps } = props;
delete otherProps.size;

useCheckAriaLabel('AddReactionButton', props);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we can't do type requirement because some (most) times, ButtonCircles should be labelled by its Tooltip. So ButtonCircle would not have aria-label or aria-labelledby directly and TS will complain

Copy link
Collaborator Author

@nataliadelmar nataliadelmar Dec 13, 2024

Choose a reason for hiding this comment

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

I have added a story to Tooltip to prove that we don't get a console warning only when we trigger a label tooltip from the ButtonCircle

className,
id,
style,
children,
orientation = DEFAULTS.ORIENTATION,
shouldRenderAsButtonGroup = DEFAULTS.SHOULD_RENDER_AS_BUTTON_GROUP,
onTabPress,
ariaControls,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we have decided not to use camelCase anymore on aria properties, to keep them consistent. I know this would cause a breaking change, so Im preparing the Cantina PR for it.

@@ -67,6 +59,8 @@ export interface Props {
ariaToolbarItemsSize: number;
}

export type Props = AriaToolbarProps & AriaLabelRequired;
Copy link
Collaborator Author

@nataliadelmar nataliadelmar Dec 13, 2024

Choose a reason for hiding this comment

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

SPARK-583000 aria-toolbar gives the wrapper a role of 'toolbar'. The SR will read toolbar with an empty label if the developer doesn't pass any aria-label(lledby) to the Toolbar.

@@ -24,6 +25,8 @@ const ButtonCircle = forwardRef((props: Props, providedRef: RefObject<HTMLButton
console.warn('MRV2: Momentum does not support a ghost inverted ButtonCircle.');
}

useCheckAriaLabel('ButtonCircle', props);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ButtonCircle can be labelled by a tooltip, so we won't require aria-label(ledby) to it. I have added a story to Tooltip that we don't get a console warning only when we trigger a label tooltip from the ButtonCircle

@@ -26,6 +27,8 @@ const ButtonCircleLink = forwardRef((props: Props, providedRef: RefObject<HTMLAn
...otherProps
} = props;

useCheckAriaLabel('ButtonCircleLink', props);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same as ButtonCircle. ButtonCircle can be labelled by a tooltip, so we won't require aria-label(ledby) to it. I have added a story to Tooltip that we don't get a console warning only when we trigger a label tooltip from the ButtonCircle

@@ -23,6 +24,8 @@ const ButtonCircleToggle = forwardRef((props: Props, providedRef: RefObject<HTML
...otherProps
} = props;

useCheckAriaLabel('ButtonCircleToggle', props);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as ButtonCircle. ButtonCircle can be labelled by a tooltip, so we won't require aria-label(ledby) to it. I have added a story to Tooltip that we don't get a console warning only when we trigger a label tooltip from the ButtonCircle


/**
* `<ControlButtons />` are used to control [close, maximize, minimize, etc] components [usually panels] they are assigned to.
*/
const ButtonControl = forwardRef((props: Props, providedRef: RefObject<HTMLButtonElement>) => {
const { className, control, isCircular, ...otherProps } = props;

useCheckAriaLabel('ButtonControl', props);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as ButtonCircle. ButtonCircle can be labelled by a tooltip, so we won't require aria-label(ledby) to it. I have added a story to Tooltip that we don't get a console warning only when we trigger a label tooltip from the ButtonCircle

@@ -67,6 +69,8 @@ export interface Props {
initialFocus?: number;
}

export type Props = ListProps & AriaLabelRequired;
Copy link
Collaborator Author

@nataliadelmar nataliadelmar Dec 13, 2024

Choose a reason for hiding this comment

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

All lists should have an aria-label(lledby) SPARK-582998
This will cause a breaking change so Im working on the Cantina PR for it.

@@ -15,6 +15,9 @@ export default {
page: DocumentationPage(Documentation, StyleDocs),
},
},
args: {
icon: 'chat',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is something I saw we missed and was causing the story to look empty

@nataliadelmar nataliadelmar added the validated If the pull request is validated automation. label Dec 13, 2024
/**
* Translated label of the reaction
*/
'aria-label': string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lottie only accepts a string to label the svg. If we don't pass any string, the svg is left unlabelled and you end up with an unlabelled image. SR reads "image". Nothing else.

For this reason, we are requiring aria-label to be passed as a reaction inside a meeting or even a chat will always be meaningful and worth reading to the unsighted user.


const ReactionBadge = forwardRef((props: Props, providedRef: RefObject<HTMLButtonElement>) => {
const { className, count, reacted, reaction, ...otherProps } = props;

useCheckAriaLabel('ReactionBadge', props);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as ButtonCircle. ButtonCircle can be labelled by a tooltip, so we won't require aria-label(ledby) to it. I have added a story to Tooltip that we don't get a console warning only when we trigger a label tooltip from the ButtonCircle


return (
<AriaToolbar
ariaLabel={ariaLabel}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we have decided to keep aria props as non-camelCase to keep consistency

@@ -7,11 +7,10 @@ import './ReactionPicker.style.scss';
import AriaToolbar from '../AriaToolbar';

const ReactionPicker: FC<Props> = (props: Props) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these props type already require aria-label(ledby)

@@ -63,9 +79,7 @@ Common.parameters = {
children: <p>Label tooltip, without label overwriteTERTIARY color, variant medium</p>,
type: 'none',
triggerComponent: (
<ButtonSimple style={{ margin: '10rem auto', display: 'flex' }}>
Hover me for label!
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this text was wrong. This is a Tooltip of type: 'none', so it does not label the button. That is why my change

@@ -198,6 +201,8 @@ export interface Props
onToggleNode?: (id: TreeNodeId, isOpen: boolean) => void;
}

export type Props = TreeProps & AriaLabelRequired;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

SPARK-582999

@@ -24,6 +24,9 @@ const Reaction: FC<Props> = (props: Props) => {
autoplay: autoPlay,
animationData: animationData,
name,
rendererSettings: {
title: props['aria-label'], // adds aria-label to the svg
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@nataliadelmar nataliadelmar marked this pull request as ready for review December 13, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validated If the pull request is validated automation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant