mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-14 03:04:14 +00:00
Adding location: Error message bypass submit button being disabled (#1367)
Form location error message submit fix
This commit is contained in:
parent
3cd55bb551
commit
7f5d6e8fdf
|
@ -197,6 +197,7 @@ export const AddLocationDialog = ({
|
|||
dialog={useDialog(dialogProps)}
|
||||
onSubmit={onSubmit}
|
||||
ctaLabel="Add"
|
||||
errorMessageException="Location is already linked"
|
||||
description={
|
||||
platform.platform === 'web'
|
||||
? 'As you are using the browser version of Spacedrive you will (for now) ' +
|
||||
|
|
|
@ -126,6 +126,7 @@ export interface DialogProps<S extends FieldValues>
|
|||
transformOrigin?: string;
|
||||
buttonsSideContent?: ReactNode;
|
||||
invertButtonFocus?: boolean; //this reverses the focus order of submit/cancel buttons
|
||||
errorMessageException?: string; //this is to bypass a specific form error message if it starts with a specific string
|
||||
}
|
||||
|
||||
export function Dialog<S extends FieldValues>({
|
||||
|
@ -181,7 +182,13 @@ export function Dialog<S extends FieldValues>({
|
|||
type="submit"
|
||||
size="sm"
|
||||
disabled={
|
||||
form.formState.isSubmitting || props.submitDisabled || !form.formState.isValid
|
||||
form.formState.isSubmitting ||
|
||||
props.submitDisabled ||
|
||||
(!form.formState.isValid || props.errorMessageException
|
||||
? !form.formState.errors.root?.serverError?.message?.startsWith(
|
||||
props.errorMessageException as string
|
||||
)
|
||||
: false)
|
||||
}
|
||||
variant={props.ctaDanger ? 'colored' : 'accent'}
|
||||
className={clsx(
|
||||
|
|
Loading…
Reference in a new issue