Skip to content

Commit

Permalink
refactor(ComboBox): ariaLabel to aria-label (#13273)
Browse files Browse the repository at this point in the history
* refactor(ComboBox): ariaLabel to aria-label

* fix: formatting

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Andrea N. Cardona <[email protected]>
  • Loading branch information
3 people authored Mar 3, 2023
1 parent c38e1a8 commit b0f39f3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ Map {
"ComboBox" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"ariaLabel": "Choose an item",
"aria-label": "Choose an item",
"direction": "bottom",
"disabled": false,
"itemToElement": null,
Expand All @@ -979,9 +979,10 @@ Map {
"type": "default",
},
"propTypes": Object {
"ariaLabel": Object {
"aria-label": Object {
"type": "string",
},
"ariaLabel": [Function],
"className": Object {
"type": "string",
},
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/components/ComboBox/ComboBox.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ export const Playground = (args) => (
);

Playground.argTypes = {
['aria-label']: {
table: {
disable: true,
},
},
ariaLabel: {
table: {
disable: true,
Expand Down
30 changes: 26 additions & 4 deletions packages/react/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ export interface ComboBoxProps
ExcludedAttributes
> {
/**
* Specify a label to be read by screen readers on the container node
* 'aria-label' of the ListBox component.
*/
['aria-label']?: string;

/**
* @deprecated please use `aria-label` instead.
* 'aria-label' of the ListBox component.
*/
ariaLabel?: string;
Expand Down Expand Up @@ -250,7 +257,8 @@ export interface ComboBoxProps

const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
const {
ariaLabel,
['aria-label']: ariaLabel,
ariaLabel: deprecatedAriaLabel,
className: containerClassName,
direction,
disabled,
Expand Down Expand Up @@ -568,7 +576,10 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
translateWithId={translateWithId}
/>
</div>
<ListBox.Menu {...getMenuProps({ 'aria-label': ariaLabel })}>
<ListBox.Menu
{...getMenuProps({
'aria-label': deprecatedAriaLabel || ariaLabel,
})}>
{isOpen
? filterItems(items, itemToString, inputValue).map(
(item, index) => {
Expand Down Expand Up @@ -634,9 +645,20 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
ComboBox.displayName = 'ComboBox';
ComboBox.propTypes = {
/**
* 'aria-label' of the ListBox component.
* Specify a label to be read by screen readers on the container node
*/
['aria-label']: PropTypes.string,

/**
* Deprecated, please use `aria-label` instead.
* Specify a label to be read by screen readers on the container note.
* 'aria-label' of the ListBox component.
*/
ariaLabel: PropTypes.string,
ariaLabel: deprecate(
PropTypes.string,
'This prop syntax has been deprecated. Please use the new `aria-label`.'
),

/**
* An optional className to add to the container node
Expand Down Expand Up @@ -813,7 +835,7 @@ ComboBox.defaultProps = {
itemToElement: null,
shouldFilterItem: defaultShouldFilterItem,
type: 'default',
ariaLabel: 'Choose an item',
['aria-label']: 'Choose an item',
direction: 'bottom',
};

Expand Down

0 comments on commit b0f39f3

Please sign in to comment.