File tree 1 file changed +10
-7
lines changed
site/src/components/Dialogs/DeleteDialog 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -35,17 +35,18 @@ export const DeleteDialog: FC<PropsWithChildren<DeleteDialogProps>> = ({
35
35
const [ confirmationText , setConfirmationText ] = useState ( "" ) ;
36
36
const [ isFocused , setIsFocused ] = useState ( false ) ;
37
37
38
- const onSubmit = ( e : FormEvent ) => {
39
- e . preventDefault ( ) ;
38
+ const deletionConfirmed = name === confirmationText ;
39
+ const onSubmit = ( event : FormEvent ) => {
40
+ event . preventDefault ( ) ;
40
41
if ( deletionConfirmed ) {
41
42
onConfirm ( ) ;
42
43
}
43
44
} ;
44
45
45
46
const confirmationId = `${ hookId } -${ DeleteDialog . name } -confirm` ;
46
- const deletionConfirmed = name === confirmationText ;
47
- const hasError =
48
- ! isFocused && ! deletionConfirmed && confirmationText . length > 0 ;
47
+ const hasError = ! deletionConfirmed && confirmationText . length > 0 ;
48
+ const displayErrorMessage = hasError && ! isFocused ;
49
+ const color = hasError ? "error" : "primary" ;
49
50
50
51
return (
51
52
< ConfirmDialog
@@ -85,11 +86,13 @@ export const DeleteDialog: FC<PropsWithChildren<DeleteDialogProps>> = ({
85
86
onFocus = { ( ) => setIsFocused ( true ) }
86
87
onBlur = { ( ) => setIsFocused ( false ) }
87
88
label = { `Name of the ${ entity } to delete` }
88
- error = { hasError }
89
+ color = { color }
90
+ error = { displayErrorMessage }
89
91
helperText = {
90
- hasError &&
92
+ displayErrorMessage &&
91
93
`${ confirmationText } does not match the name of this ${ entity } `
92
94
}
95
+ InputProps = { { color } }
93
96
inputProps = { {
94
97
[ "data-testid" ] : "delete-dialog-name-confirmation" ,
95
98
} }
You can’t perform that action at this time.
0 commit comments