Skip to content

Commit 2ff3f51

Browse files
committed
chore(combobox): expose typeahead prop and fix all the descriptions
1 parent 9899ab3 commit 2ff3f51

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

packages/web-components/src/components/combo-box/combo-box.stories.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2019, 2023
2+
* Copyright IBM Corp. 2019, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -66,6 +66,7 @@ const defaultArgs = {
6666
readOnly: false,
6767
size: null,
6868
titleText: 'Label',
69+
typeahead: false,
6970
value: '',
7071
warn: false,
7172
warnText: 'Warning message goes here',
@@ -74,28 +75,28 @@ const defaultArgs = {
7475
const controls = {
7576
allowCustomValue: {
7677
control: 'boolean',
77-
description: `Allow entering values that do not match any of the provided items.`,
78+
description: `Specify whether or not the ComboBox should allow a value that is not in the list to be entered in the input.`,
7879
},
7980
disabled: {
8081
control: 'boolean',
81-
description: `Specify if the dropdown should be disabled, or not.`,
82+
description: `Specify if the control should be disabled, or not.`,
8283
},
8384
direction: {
8485
control: 'select',
8586
options: directionOptions,
86-
description: `Dropdown direction`,
87+
description: `Specify the direction of the combobox dropdown. Can be either top or bottom.`,
8788
},
8889
hideLabel: {
8990
control: 'boolean',
9091
description: `Specify if the title text should be hidden, or not.`,
9192
},
9293
helperText: {
9394
control: 'text',
94-
description: `The helper text for the dropdown.`,
95+
description: `Provide helper text that is used alongside the control label for additional help.`,
9596
},
9697
invalid: {
9798
control: 'boolean',
98-
description: `Specify if the dropdown should display an invalid icon, or not.`,
99+
description: `Specify if the currently selected value is invalid.`,
99100
},
100101
invalidText: {
101102
control: 'text',
@@ -107,16 +108,20 @@ const controls = {
107108
},
108109
readOnly: {
109110
control: 'boolean',
110-
description: `Specify if the dropdown should be read only, or not.`,
111+
description: `Specify whether or not the component is read-only.`,
111112
},
112113
size: {
113114
control: 'select',
114115
options: sizes,
115-
description: `Dropdown size.`,
116+
description: `Specify the size of the ListBox. Currently supports either \`sm\`, \`md\` or \`lg\` as an option.`,
116117
},
117118
titleText: {
118119
control: 'text',
119-
description: `Text that will be read by a screen reader when visiting this control.`,
120+
description: `Provide text to be used in a <label> element that is tied to the combobox via ARIA attributes.`,
121+
},
122+
typeahead: {
123+
control: 'boolean',
124+
description: `**Experimental**: will enable autocomplete and typeahead for the input field.`,
120125
},
121126
value: {
122127
control: 'text',
@@ -128,7 +133,7 @@ const controls = {
128133
},
129134
warnText: {
130135
control: 'text',
131-
description: `Text that is displayed when the control is in warning state.`,
136+
description: `Provide the text that is displayed when the control is in warning state.`,
132137
},
133138
};
134139

@@ -156,6 +161,7 @@ export const Default = {
156161
type,
157162
invalidText,
158163
value,
164+
typeahead,
159165
} = args ?? {};
160166
return html`
161167
<cds-combo-box
@@ -173,7 +179,8 @@ export const Default = {
173179
value=${ifDefined(value)}
174180
label=${ifDefined(label)}
175181
?warn=${warn}
176-
warn-text=${ifDefined(warnText)}>
182+
warn-text=${ifDefined(warnText)}
183+
?typeahead=${typeahead}>
177184
${items.map(
178185
(elem) => html`
179186
<cds-combo-box-item ?disabled=${elem.disabled} value="${elem.value}"
@@ -242,6 +249,7 @@ export const AllowCustomValue = {
242249
type,
243250
invalidText,
244251
value,
252+
typeahead,
245253
} = args ?? {};
246254
return html`
247255
<cds-combo-box
@@ -260,6 +268,7 @@ export const AllowCustomValue = {
260268
label=${ifDefined(label)}
261269
?warn=${warn}
262270
warn-text=${ifDefined(warnText)}
271+
?typeahead=${typeahead}
263272
should-filter-item>
264273
<cds-combo-box-item value="apple">Apple</cds-combo-box-item>
265274
<cds-combo-box-item value="orange">Orange</cds-combo-box-item>
@@ -353,6 +362,7 @@ export const WithAILabel = {
353362
type,
354363
invalidText,
355364
value,
365+
typeahead,
356366
} = args ?? {};
357367
return html`
358368
<cds-combo-box
@@ -370,7 +380,8 @@ export const WithAILabel = {
370380
value=${ifDefined(value)}
371381
label=${ifDefined(label)}
372382
?warn=${warn}
373-
warn-text=${ifDefined(warnText)}>
383+
warn-text=${ifDefined(warnText)}
384+
?typeahead=${typeahead}>
374385
<cds-ai-label alignment="bottom-left">
375386
${content}${actions}</cds-ai-label
376387
>
@@ -411,6 +422,7 @@ export const WithLayer = {
411422
type,
412423
invalidText,
413424
value,
425+
typeahead,
414426
} = args ?? {};
415427
return html`
416428
<sb-template-layers>
@@ -430,7 +442,8 @@ export const WithLayer = {
430442
value=${ifDefined(value)}
431443
label=${ifDefined(label)}
432444
?warn=${warn}
433-
warn-text=${ifDefined(warnText)}>
445+
warn-text=${ifDefined(warnText)}
446+
?typeahead=${typeahead}>
434447
${items.map(
435448
(elem) => html`
436449
<cds-combo-box-item

packages/web-components/src/components/combo-box/combo-box.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,12 @@ class CDSComboBox extends CDSDropdown {
465465
})
466466
shouldFilterItem: boolean | ShouldFilterItem = false;
467467

468+
/**
469+
* **Experimental**: will enable autocomplete and typeahead for the input field.
470+
*/
471+
@property({ type: Boolean, reflect: true })
472+
typeahead = false;
473+
468474
shouldUpdate(changedProperties) {
469475
super.shouldUpdate(changedProperties);
470476
const { _selectedItemContent: selectedItemContent } = this;

0 commit comments

Comments
 (0)