Skip to content

Commit d4a071a

Browse files
authored
fix(ComboBox): fix fully controlled story and delete test story (#18680)
1 parent faf6498 commit d4a071a

File tree

2 files changed

+3
-29
lines changed

2 files changed

+3
-29
lines changed

packages/react/src/components/ComboBox/ComboBox-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ describe('ComboBox', () => {
330330
expect(findInputNode()).toHaveDisplayValue(mockProps.items[1]);
331331
});
332332

333-
it('should not revert to initialSelectedItem after clearing selection in uncontrolled mode', async () => {
333+
it('should not revert to `initialSelectedItem` after clearing selection in uncontrolled mode', async () => {
334334
// Render a non-fully controlled `ComboBox` using `initialSelectedItem`.
335335
render(
336336
<ComboBox {...mockProps} initialSelectedItem={mockProps.items[0]} />
@@ -348,7 +348,7 @@ describe('ComboBox', () => {
348348
expect(findInputNode()).toHaveDisplayValue('');
349349
});
350350

351-
it('should ignore updates to initialSelectedItem after initial render in uncontrolled mode', async () => {
351+
it('should ignore updates to `initialSelectedItem` after initial render in uncontrolled mode', async () => {
352352
// Render a non-fully controlled `ComboBox` using `initialSelectedItem`.
353353
const { rerender } = render(
354354
<ComboBox {...mockProps} initialSelectedItem={mockProps.items[0]} />

packages/react/src/components/ComboBox/ComboBox.stories.js

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,14 @@ export const _fullyControlled = (args) => {
384384
return (
385385
<div>
386386
<ComboBox
387+
{...args}
387388
onChange={onChange}
388389
id="carbon-combobox"
389390
items={options}
390391
selectedItem={value}
391392
itemToString={(item) => (item ? item.text : '')}
392393
titleText="Fully Controlled ComboBox title"
393394
helperText="Combobox helper text"
394-
{...args}
395395
/>
396396
<div
397397
style={{
@@ -410,32 +410,6 @@ export const _fullyControlled = (args) => {
410410

411411
_fullyControlled.argTypes = { ...sharedArgTypes };
412412

413-
export const _fullyControlled2 = () => {
414-
const [selectedItem, setSelectedItem] = useState(null);
415-
416-
return (
417-
<div
418-
style={{
419-
display: 'flex',
420-
flexDirection: 'column',
421-
gap: '1rem',
422-
width: '256px',
423-
}}>
424-
<ComboBox
425-
id="carbon-combobox"
426-
items={['1', '2', '3']}
427-
onChange={({ selectedItem }) => setSelectedItem(selectedItem)}
428-
selectedItem={selectedItem}
429-
titleText="Fully Controlled ComboBox title"
430-
/>
431-
<Button kind="danger" onClick={() => setSelectedItem(null)} size="md">
432-
Reset
433-
</Button>
434-
<p>Selected value: {`${selectedItem}`}</p>
435-
</div>
436-
);
437-
};
438-
439413
AutocompleteWithTypeahead.argTypes = {
440414
onChange: { action: 'onChange' },
441415
};

0 commit comments

Comments
 (0)