mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-18 13:26:00 -04:00
Adding location: Error message bypass submit button being disabled (#1367)
Form location error message submit fix
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user