mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-13 07:47:05 +08:00
CB-4335 added to useForm submit events handling
This commit is contained in:
@@ -21,7 +21,7 @@ export interface IChangeData {
|
||||
export interface IFormContext {
|
||||
ref: HTMLFormElement | null;
|
||||
onValidate: SyncExecutor;
|
||||
onSubmit: SyncExecutor;
|
||||
onSubmit: SyncExecutor<SubmitEvent | undefined>;
|
||||
onChange: IExecutor<IChangeData>;
|
||||
parent: IFormContext | null;
|
||||
disableEnterSubmit: boolean;
|
||||
|
||||
@@ -22,7 +22,7 @@ interface IOptions {
|
||||
|
||||
export function useForm(options?: IOptions): IFormContext {
|
||||
let parentForm = useContext(FormContext);
|
||||
const [submittingExecutor] = useState(() => new SyncExecutor());
|
||||
const [submittingExecutor] = useState(() => new SyncExecutor<SubmitEvent | undefined>());
|
||||
const [validationExecutor] = useState(() => new SyncExecutor());
|
||||
const [changeExecutor] = useState(() => new Executor<IChangeData>());
|
||||
|
||||
@@ -49,7 +49,7 @@ export function useForm(options?: IOptions): IFormContext {
|
||||
|
||||
useExecutor({
|
||||
executor: submittingExecutor,
|
||||
handlers: [() => options?.onSubmit?.()],
|
||||
handlers: [event => options?.onSubmit?.(event)],
|
||||
});
|
||||
|
||||
const context = useObjectRef<IFormContext>(
|
||||
@@ -93,7 +93,7 @@ export function useForm(options?: IOptions): IFormContext {
|
||||
event?.preventDefault();
|
||||
|
||||
if (this.validate()) {
|
||||
this.onSubmit.execute();
|
||||
this.onSubmit.execute(event);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user