File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
modules/preview-react/color-picker/lib Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -172,16 +172,21 @@ export const ColorPicker = ({
172
172
...elemProps
173
173
} : ColorPickerProps ) => {
174
174
const [ validHexValue , setValidHexValue ] = React . useState ( '' ) ;
175
+ const [ disabled , setDisabled ] = React . useState ( true ) ;
175
176
const [ customHexValue , setCustomHexValue ] = React . useState (
176
177
isCustomColor ( colorSet , value ) ? value : ''
177
178
) ;
178
179
179
180
const onCustomHexChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
180
181
setCustomHexValue ( event . target . value ) ;
181
182
setValidHexValue ( '' ) ;
183
+ setDisabled ( true ) ;
182
184
} ;
183
185
184
- const onValidCustomHexChange = ( validHexValue : string ) => setValidHexValue ( validHexValue ) ;
186
+ const onValidCustomHexChange = ( validHexValue : string ) => {
187
+ setValidHexValue ( validHexValue ) ;
188
+ setDisabled ( false ) ;
189
+ } ;
185
190
186
191
const onSubmit = ( event : React . FormEvent ) => {
187
192
if ( onSubmitClick ) {
@@ -207,7 +212,12 @@ export const ColorPicker = ({
207
212
showCheck = { value === validHexValue || value === customHexValue }
208
213
/>
209
214
</ ColorInputAndLabel >
210
- < CheckButton aria-label = { submitLabel } icon = { checkIcon } type = "submit" />
215
+ < CheckButton
216
+ aria-label = { submitLabel }
217
+ icon = { checkIcon }
218
+ type = "submit"
219
+ disabled = { disabled }
220
+ />
211
221
</ ColorInputWrapper >
212
222
) }
213
223
</ ColorPickerContainer >
You can’t perform that action at this time.
0 commit comments