Skip to content

fix(ListBox): rename colliding symbols and fix prop types #19232

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

Merged
merged 1 commit into from
Apr 29, 2025
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
Expand Up @@ -3874,6 +3874,15 @@ Map {
"translateWithId": Object {
"type": "func",
},
"type": Object {
"args": Array [
Array [
"default",
"inline",
],
],
"type": "oneOf",
},
"useTitleInItem": Object {
"type": "bool",
},
Expand Down
7 changes: 2 additions & 5 deletions packages/react/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ import {
WarningFilled,
} from '@carbon/icons-react';
import isEqual from 'react-fast-compare';
import ListBox, {
PropTypes as ListBoxPropTypes,
ListBoxSize,
} from '../ListBox';
import ListBox, { ListBoxSizePropType, type ListBoxSize } from '../ListBox';
import { ListBoxTrigger, ListBoxSelection } from '../ListBox/next';
import { match, keys } from '../../internal/keyboard';
import { useId } from '../../internal/useId';
Expand Down Expand Up @@ -1390,7 +1387,7 @@ ComboBox.propTypes = {
/**
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
*/
size: ListBoxPropTypes.ListBoxSize,
size: ListBoxSizePropType,

slug: deprecate(
PropTypes.node,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2023
* Copyright IBM Corp. 2016, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -8,7 +8,7 @@
import PropTypes from 'prop-types';
import React from 'react';
import cx from 'classnames';
import { ListBoxSize, PropTypes as ListBoxPropTypes } from '../ListBox';
import { ListBoxSizePropType, type ListBoxSize } from '../ListBox';
import { usePrefix } from '../../internal/usePrefix';
import { ReactAttr } from '../../types/common';

Expand Down Expand Up @@ -69,7 +69,7 @@ DropdownSkeleton.propTypes = {
/**
* Specify the size of the ListBox.
*/
size: ListBoxPropTypes.ListBoxSize,
size: ListBoxSizePropType,
};

export default DropdownSkeleton;
Expand Down
11 changes: 6 additions & 5 deletions packages/react/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ import {
WarningFilled,
} from '@carbon/icons-react';
import ListBox, {
ListBoxSizePropType,
ListBoxTypePropType,
type ListBoxMenuIconTranslationKey,
ListBoxSize,
ListBoxType,
PropTypes as ListBoxPropTypes,
type ListBoxSize,
type ListBoxType,
} from '../ListBox';
import mergeRefs from '../../tools/mergeRefs';
import deprecate from '../../prop-types/deprecate';
Expand Down Expand Up @@ -882,7 +883,7 @@ Dropdown.propTypes = {
/**
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
*/
size: ListBoxPropTypes.ListBoxSize,
size: ListBoxSizePropType,

/**
* **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
Expand All @@ -907,7 +908,7 @@ Dropdown.propTypes = {
/**
* The dropdown type, `default` or `inline`
*/
type: ListBoxPropTypes.ListBoxType,
type: ListBoxTypePropType,

/**
* Specify whether the control is currently in warning state
Expand Down
13 changes: 9 additions & 4 deletions packages/react/src/components/ListBox/ListBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2023
* Copyright IBM Corp. 2016, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -9,7 +9,12 @@ import cx from 'classnames';
import React, { type KeyboardEvent, type MouseEvent, useContext } from 'react';
import PropTypes from 'prop-types';
import deprecate from '../../prop-types/deprecate';
import { ListBoxType, ListBoxSize } from './ListBoxPropTypes';
import {
ListBoxSizePropType,
ListBoxTypePropType,
type ListBoxSize,
type ListBoxType,
} from '.';
import { usePrefix } from '../../internal/usePrefix';
import { FormContext } from '../FluidForm';
import { ForwardRefReturn, ReactAttr } from '../../types/common';
Expand Down Expand Up @@ -207,13 +212,13 @@ ListBox.propTypes = {
/**
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
*/
size: ListBoxSize,
size: ListBoxSizePropType,

/**
* Specify the "type" of the ListBox. Currently supports either `default` or
* `inline` as an option.
*/
type: ListBoxType,
type: ListBoxTypePropType,

/**
* Specify whether the control is currently in warning state
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/components/ListBox/ListBoxPropTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2016, 2023
* Copyright IBM Corp. 2016, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -13,5 +13,5 @@ const listBoxSizes = ['sm', 'md', 'lg'] as const;
export type ListBoxType = (typeof listBoxTypes)[number];
export type ListBoxSize = (typeof listBoxSizes)[number];

export const ListBoxType = PropTypes.oneOf<ListBoxType>(listBoxTypes);
export const ListBoxSize = PropTypes.oneOf<ListBoxSize>(listBoxSizes);
export const ListBoxTypePropType = PropTypes.oneOf(listBoxTypes);
export const ListBoxSizePropType = PropTypes.oneOf(listBoxSizes);
2 changes: 0 additions & 2 deletions packages/react/src/components/ListBox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ Currently, a `ListBox` is broken up into the following pieces:
- `ListBoxMenu`: container component for the menu of options available in a
`ListBox`
- `ListBoxMenuItem`: container component for an option in a `ListBoxMenu`

In addition, we have `ListBox`-specific `prop` types in `ListBoxPropTypes`.
3 changes: 1 addition & 2 deletions packages/react/src/components/ListBox/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* Copyright IBM Corp. 2016, 2023
* Copyright IBM Corp. 2016, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

export * as PropTypes from './ListBoxPropTypes';
export * from './ListBoxPropTypes';

import ListBoxInternal, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ import {
type MultiSelectSortingProps,
sortingPropTypes,
} from './MultiSelectPropTypes';
import ListBox, { PropTypes as ListBoxPropTypes } from '../ListBox';
import ListBox, {
ListBoxSizePropType,
ListBoxTypePropType,
type ListBoxSize,
type ListBoxType,
} from '../ListBox';
import { ListBoxTrigger, ListBoxSelection } from '../ListBox/next';
import { match, keys } from '../../internal/keyboard';
import { defaultItemToString } from './tools/itemToString';
Expand Down Expand Up @@ -281,7 +286,7 @@ export interface FilterableMultiSelectProps<ItemType>
* Specify the size of the ListBox.
* Currently, supports either `sm`, `md` or `lg` as an option.
*/
size?: 'sm' | 'md' | 'lg';
size?: ListBoxSize;

/**
* @deprecated please use decorator instead.
Expand All @@ -295,7 +300,7 @@ export interface FilterableMultiSelectProps<ItemType>
*/
titleText?: ReactNode;

type?: 'default' | 'inline';
type?: ListBoxType;

/**
* Specify title to show title on hover
Expand Down Expand Up @@ -1180,7 +1185,7 @@ FilterableMultiSelect.propTypes = {
/**
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
*/
size: ListBoxPropTypes.ListBoxSize,
size: ListBoxSizePropType,

slug: deprecate(
PropTypes.node,
Expand All @@ -1200,6 +1205,8 @@ FilterableMultiSelect.propTypes = {
*/
translateWithId: PropTypes.func,

type: ListBoxTypePropType,

/**
* Specify title to show title on hover
*/
Expand Down
11 changes: 6 additions & 5 deletions packages/react/src/components/MultiSelect/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import React, {
useCallback,
} from 'react';
import ListBox, {
ListBoxSize,
ListBoxType,
PropTypes as ListBoxPropTypes,
ListBoxSizePropType,
ListBoxTypePropType,
type ListBoxSize,
type ListBoxType,
} from '../ListBox';
import {
MultiSelectSortingProps,
Expand Down Expand Up @@ -1099,7 +1100,7 @@ MultiSelect.propTypes = {
/**
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
*/
size: ListBoxPropTypes.ListBoxSize,
size: ListBoxSizePropType,

slug: deprecate(
PropTypes.node,
Expand Down Expand Up @@ -1142,7 +1143,7 @@ MultiSelect.propTypes = {
/**
* Specify 'inline' to create an inline multi-select.
*/
type: PropTypes.oneOf(['default', 'inline']),
type: ListBoxTypePropType,

/**
* Specify title to show title on hover
Expand Down
Loading