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(ListBoxTrigger): support title on ListBoxTrigger #8094

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions packages/react/src/components/ComboBox/ComboBox-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { action } from '@storybook/addon-actions';
import { boolean, select, text } from '@storybook/addon-knobs';
import { boolean, object, select, text } from '@storybook/addon-knobs';
import ComboBox from '../ComboBox';
import mdx from './ComboBox.mdx';

Expand Down Expand Up @@ -91,17 +91,29 @@ const props = () => ({
'Warning state text (warnText)',
'This mode may perform worse on older machines'
),
listBoxMenuIconTranslationIds: object(
'Listbox menu icon translation IDs (for translateWithId callback)',
{
'close.menu': 'Close menu',
'open.menu': 'Open menu',
'clear.selection': 'Clear selection',
}
),
});

export const Playground = () => (
<div style={{ width: 300 }}>
<ComboBox
items={items}
itemToString={(item) => (item ? item.text : '')}
{...props()}
/>
</div>
);
export const Playground = () => {
const { listBoxMenuIconTranslationIds, ...comboBoxProps } = props();
return (
<div style={{ width: 300 }}>
<ComboBox
{...comboBoxProps}
items={items}
itemToString={(item) => (item ? item.text : '')}
translateWithId={(id) => listBoxMenuIconTranslationIds[id]}
/>
</div>
);
};

export const disabled = () => (
<div style={{ width: 300 }}>
Expand Down
19 changes: 17 additions & 2 deletions packages/react/src/components/Dropdown/Dropdown-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

import React from 'react';
import { action } from '@storybook/addon-actions';
import { withKnobs, boolean, select, text } from '@storybook/addon-knobs';
import {
withKnobs,
boolean,
object,
select,
text,
} from '@storybook/addon-knobs';
import Dropdown from '../Dropdown';
import DropdownSkeleton from './Dropdown.Skeleton';
import mdx from './Dropdown.mdx';
Expand Down Expand Up @@ -78,6 +84,13 @@ const props = () => ({
'Warning state text (warnText)',
'This mode may perform worse on older machines'
),
listBoxMenuIconTranslationIds: object(
'Listbox menu icon translation IDs (for translateWithId callback)',
{
'close.menu': 'Close menu',
'open.menu': 'Open menu',
}
),
});

export default {
Expand Down Expand Up @@ -125,12 +138,14 @@ export const Inline = () => (
);

export const Playground = () => {
const { listBoxMenuIconTranslationIds, ...dropdownProps } = props();
return (
<div style={{ width: 300 }}>
<Dropdown
{...props()}
{...dropdownProps}
items={items}
itemToString={(item) => (item ? item.text : '')}
translateWithId={(id) => listBoxMenuIconTranslationIds[id]}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const ListBoxTrigger = ({ isOpen, translateWithId: t, ...rest }) => {
<button
{...rest}
aria-label={description}
title={description}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think for the trigger we removed title based on one of Carolyn's suggestions. It seems like having both would basically repeat the same information twice for a screen reader user. I think an alternative she suggested was to use only title if we need to offer it (remove the `aria-label in this case). This was the comment IIRC: #6938 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

it is ok to keep the <title>Close menu</title> for sighted mouse users, but please change it to <title>Close</title> (which is less verbose, and removes the confusing word "menu")

are you referring to this point?

on a side note, she and I briefly discussed this for #4185 / #8090 and from testing the combobox, multiselect, number input, etc it doesn't seem to be double speaking (in VO at least)

image

the current multiselect places the title under the SVG rather than the button itself, so that may be an option as well but right now it doesn't seem like either approach is causing VO to read twice

Copy link
Contributor

Choose a reason for hiding this comment

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

@emyarod I'm not sure which screen reader it shows up in, just was going off of what Carolyn shared. Just was sharing that if we needed the title then we could just drop the aria-label altogether based on what she shared.

className={className}
type="button"
tabIndex="-1">
Expand Down