Skip to content

Commit b931829

Browse files
feat: add option to allow clearing selection in dropdown (#1040)
1 parent 52b1da6 commit b931829

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

.changeset/serious-wasps-agree.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ensembleui/react-kitchen-sink": patch
3+
"@ensembleui/react-runtime": patch
4+
---
5+
6+
Add option to allow clear input for dropdown

apps/kitchen-sink/src/ensemble/screens/widgets.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,17 @@ View:
869869
Text:
870870
text: Here is my label 2
871871
value: 222
872+
- Dropdown:
873+
label: Ability to stop clearing selection
874+
hintText: Hint Text
875+
allowClear: ${false}
876+
styles:
877+
dropdownBorderWidth: 3px
878+
items:
879+
- label: Option 1
880+
value: 1
881+
- label: Option 2
882+
value: 2
872883
- Card:
873884
styles:
874885
maxWidth: unset

packages/runtime/src/widgets/Form/Dropdown.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface SelectOption {
4848
}
4949

5050
export type DropdownProps = {
51+
allowClear?: boolean;
5152
items?: SelectOption[];
5253
/* deprecated, use onChange */
5354
onItemSelect: EnsembleAction;
@@ -302,6 +303,7 @@ const Dropdown: React.FC<DropdownProps> = (props) => {
302303
<div ref={rootRef} style={{ flex: 1, ...formItemStyles }}>
303304
<EnsembleFormItem values={values}>
304305
<Select
306+
allowClear={values?.allowClear ?? true}
305307
className={`${values?.styles?.names || ""} ${id}_input`}
306308
defaultValue={values?.value}
307309
disabled={values?.enabled === false}

0 commit comments

Comments
 (0)