Skip to content

Commit

Permalink
feat: Moves inline token api out of private
Browse files Browse the repository at this point in the history
  • Loading branch information
Katie George committed Jan 10, 2025
1 parent 67c06fa commit cf0e29b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/multiselect/__tests__/multiselect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,10 @@ test('Trigger receives focus when autofocus is true', () => {
expect(document.activeElement).toBe(wrapper.findTrigger().getElement());
});

describe('With inline tokens (private API)', () => {
describe('With inline tokens', () => {
it('can render inline tokens', () => {
const { wrapper } = renderMultiselect(
<Multiselect {...{ inlineTokens: true }} options={defaultOptions} selectedOptions={[defaultOptions[0]]} />
<Multiselect inlineTokens={true} options={defaultOptions} selectedOptions={[defaultOptions[0]]} />
);

// Trigger contains token labels and the number of selected items
Expand All @@ -666,7 +666,7 @@ describe('With inline tokens (private API)', () => {

it('shows placeholder when no items are selected', () => {
const { wrapper } = renderMultiselect(
<Multiselect {...{ inlineTokens: true }} selectedOptions={[]} placeholder="Choose something" />
<Multiselect inlineTokens={true} selectedOptions={[]} placeholder="Choose something" />
);

expect(wrapper.findTrigger().getElement()).toHaveTextContent('Choose something');
Expand All @@ -677,7 +677,7 @@ describe('With inline tokens (private API)', () => {
{ value: '1', label: 'First', description: 'description', tags: ['tag'], labelTag: 'label' },
];
const { wrapper } = renderMultiselect(
<Multiselect {...{ inlineTokens: true }} options={extendedOptions} selectedOptions={[extendedOptions[0]]} />
<Multiselect inlineTokens={true} options={extendedOptions} selectedOptions={[extendedOptions[0]]} />
);

expect(wrapper.findTrigger().getElement()).toHaveTextContent('First');
Expand All @@ -689,7 +689,7 @@ describe('With inline tokens (private API)', () => {
it('shows multiple selected options inline', () => {
const { wrapper } = renderMultiselect(
<Multiselect
{...{ inlineTokens: true }}
inlineTokens={true}
options={defaultOptions}
selectedOptions={[defaultOptions[0], defaultOptions[1], defaultOptions[2]]}
/>
Expand Down
4 changes: 4 additions & 0 deletions src/multiselect/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export interface MultiselectProps extends BaseSelectProps {
* Only use this if the selected options are displayed elsewhere on the page.
*/
hideTokens?: boolean;
/**
* Shows tokens inside the input instead of below.
*/
inlineTokens?: boolean;
/**
* Specifies an `aria-label` for the token deselection button.
* @i18n
Expand Down
2 changes: 1 addition & 1 deletion src/multiselect/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type InternalMultiselectProps = SomeRequired<
MultiselectProps,
'options' | 'selectedOptions' | 'filteringType' | 'statusType' | 'keepOpen' | 'hideTokens'
> &
InternalBaseComponentProps & { inlineTokens?: boolean };
InternalBaseComponentProps;

const InternalMultiselect = React.forwardRef(
(
Expand Down

0 comments on commit cf0e29b

Please sign in to comment.