Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: update role and accname for non-hidden icon button",
"packageName": "@fluentui/react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,6 @@ exports[`Pagination render comboBox Pagination correctly 1`] = `
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseUp={[Function]}
role="presentation"
tabIndex={-1}
type="button"
>
Expand Down
10 changes: 5 additions & 5 deletions packages/react/src/components/ComboBox/ComboBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe('ComboBox', () => {
const combobox = getByRole('combobox');
userEvent.type(combobox, 'f{enter}');

const caretdownButton = getByRole('presentation', { hidden: true });
const caretdownButton = getByRole('button');
userEvent.click(caretdownButton);

expect(getAllByRole('option')).toHaveLength(DEFAULT_OPTIONS.length);
Expand All @@ -233,7 +233,7 @@ describe('ComboBox', () => {
const combobox = getByRole('combobox');
userEvent.type(combobox, 'f{enter}');

const caretdownButton = getByRole('presentation', { hidden: true });
const caretdownButton = getByRole('button');
userEvent.click(caretdownButton);

const options = getAllByRole('option');
Expand Down Expand Up @@ -555,7 +555,7 @@ describe('ComboBox', () => {
const { getByRole, queryAllByRole } = render(
<ComboBox defaultSelectedKey="1" options={DEFAULT_OPTIONS2} disabled />,
);
const caretdownButton = getByRole('presentation', { hidden: true });
const caretdownButton = getByRole('button');
userEvent.click(caretdownButton);
expect(queryAllByRole('option')).toHaveLength(0);
});
Expand Down Expand Up @@ -1189,7 +1189,7 @@ describe('ComboBox', () => {
<ComboBox multiSelect options={DEFAULT_OPTIONS} allowFreeform />,
);
const combobox = getByRole('combobox');
const caretdownButton = getByRole('presentation', { hidden: true });
const caretdownButton = getByRole('button');
userEvent.type(combobox, comboBoxOption.text);
//click on container to trigger onBlur
userEvent.click(container);
Expand All @@ -1215,7 +1215,7 @@ describe('ComboBox', () => {

const { container, getByRole, getAllByRole } = render(<ComboBox options={DEFAULT_OPTIONS} allowFreeform />);
const combobox = getByRole('combobox');
const caretdownButton = getByRole('presentation', { hidden: true });
const caretdownButton = getByRole('button');
userEvent.type(combobox, comboBoxOption.text);
userEvent.click(container);
expect(combobox.getAttribute('value')).toEqual(comboBoxOption.text);
Expand Down
10 changes: 7 additions & 3 deletions packages/react/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@ class ComboBoxInternal extends React.Component<IComboBoxInternalProps, IComboBox
: placeholderProp;

const labelledBy = [this.props['aria-labelledby'], label && this._id + '-label'].join(' ').trim();
const labelProps = {
'aria-labelledby': labelledBy ? labelledBy : undefined,
'aria-label': ariaLabel && !label ? ariaLabel : undefined,
};

return (
<div
Expand Down Expand Up @@ -618,8 +622,7 @@ class ComboBoxInternal extends React.Component<IComboBoxInternalProps, IComboBox
aria-autocomplete={this._getAriaAutoCompleteValue()}
role="combobox"
readOnly={disabled}
aria-labelledby={labelledBy ? labelledBy : undefined}
aria-label={ariaLabel && !label ? ariaLabel : undefined}
{...labelProps}
aria-describedby={
errorMessage !== undefined ? mergeAriaAttributeValues(ariaDescribedBy, errorMessageId) : ariaDescribedBy
}
Expand All @@ -643,8 +646,9 @@ class ComboBoxInternal extends React.Component<IComboBoxInternalProps, IComboBox
<IconButton
className={'ms-ComboBox-CaretDown-button'}
styles={this._getCaretButtonStyles()}
role="presentation"
role={isButtonAriaHidden ? 'presentation' : undefined}
aria-hidden={isButtonAriaHidden}
{...(!isButtonAriaHidden ? labelProps : undefined)}
data-is-focusable={false}
tabIndex={-1}
onClick={this._onComboBoxClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ exports[`ComboBox Renders correctly 1`] = `
forced-color-adjust: none;
}
data-is-focusable="false"
role="presentation"
tabindex="-1"
type="button"
>
Expand Down Expand Up @@ -609,7 +608,6 @@ exports[`ComboBox Renders correctly when open 1`] = `
forced-color-adjust: none;
}
data-is-focusable="false"
role="presentation"
tabindex="-1"
type="button"
>
Expand Down Expand Up @@ -1377,7 +1375,6 @@ exports[`ComboBox Renders correctly when opened in multi-select mode 1`] = `
forced-color-adjust: none;
}
data-is-focusable="false"
role="presentation"
tabindex="-1"
type="button"
>
Expand Down Expand Up @@ -2284,7 +2281,6 @@ exports[`ComboBox renders with a Keytip correctly 1`] = `
forced-color-adjust: none;
}
data-is-focusable="false"
role="presentation"
tabindex="-1"
type="button"
>
Expand Down