Skip to content

Commit 2f9561a

Browse files
committed
ColorHelper: Auto select when there is only one choice left
1 parent 0089feb commit 2f9561a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

stories/ColorHelper/Search.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ export function Search(props: Props) {
114114
>
115115
<Select
116116
label={`Filter by context (${contextes.length})`}
117-
disabled={contextes.length === 0}
117+
disabled={contextes.length === 1}
118118
nativeSelectProps={{
119119
"onChange": event =>
120120
onContextChange(event.target.value || (undefined as any)),
121-
"value": context ?? ""
121+
"value": contextes.length === 1 ? contextes[0] : context ?? ""
122122
}}
123123
>
124124
{[undefined, ...contextes].map(context => (
@@ -129,11 +129,11 @@ export function Search(props: Props) {
129129
</Select>
130130
<Select
131131
label={`Filter by color name (${colors.length})`}
132-
disabled={colors.length === 0}
132+
disabled={colors.length === 1}
133133
nativeSelectProps={{
134134
"onChange": event =>
135135
onColorChange(event.target.value || (undefined as any)),
136-
"value": color ?? ""
136+
"value": colors.length === 1 ? colors[0] : color ?? ""
137137
}}
138138
>
139139
{[undefined, ...colors].map(color => (
@@ -144,11 +144,11 @@ export function Search(props: Props) {
144144
</Select>
145145
<Select
146146
label={`Filter by usage (${usages.length})`}
147-
disabled={usages.length === 0}
147+
disabled={usages.length === 1}
148148
nativeSelectProps={{
149149
"onChange": event =>
150150
onUsageChange(event.target.value || (undefined as any)),
151-
"value": usage ?? ""
151+
"value": usages.length === 1 ? usages[0] : usage ?? ""
152152
}}
153153
>
154154
{[undefined, ...usages].map(usage => (

0 commit comments

Comments
 (0)