Skip to content

Commit

Permalink
CB-5691 removes unneeded prop: disableCtrlEnterSubmit
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyteleshev committed Nov 8, 2024
1 parent 1227bcc commit 23d56c8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
16 changes: 1 addition & 15 deletions webapp/packages/core-blocks/src/FormControls/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,14 @@ type FormDetailedProps = Omit<React.DetailedHTMLProps<React.FormHTMLAttributes<H
context?: IFormContext;
disabled?: boolean;
disableEnterSubmit?: boolean;
disableCtrlEnterSubmit?: boolean;
focusFirstChild?: boolean;
contents?: boolean;
onSubmit?: (event?: SubmitEvent) => Promise<void> | void;
onChange?: FormChangeHandler;
};

export const Form = forwardRef<HTMLFormElement, FormDetailedProps>(function Form(
{
context,
disabled: disabledProp,
disableEnterSubmit,
disableCtrlEnterSubmit,
focusFirstChild,
children,
contents,
style,
onSubmit,
onChange,
...rest
},
{ context, disabled: disabledProp, disableEnterSubmit, focusFirstChild, children, contents, style, onSubmit, onChange, ...rest },
ref,
) {
const st = useS(styles);
Expand All @@ -50,7 +37,6 @@ export const Form = forwardRef<HTMLFormElement, FormDetailedProps>(function Form

const formContext = useForm({
disableEnterSubmit,
disableCtrlEnterSubmit,
parent: context,
async onSubmit(event) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export interface IFormContext {
onChange: IExecutor<IChangeData>;
parent: IFormContext | null;
disableEnterSubmit: boolean;
disableCtrlEnterSubmit: boolean;
setRef: (ref: HTMLFormElement | null) => void;
change: FormChangeHandler;
keyDown: KeyHandler;
Expand Down
6 changes: 2 additions & 4 deletions webapp/packages/core-blocks/src/FormControls/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { type FormChangeHandler, FormContext, type IChangeData, type IFormContex
interface IOptions {
parent?: IFormContext;
disableEnterSubmit?: boolean;
disableCtrlEnterSubmit?: boolean;
onSubmit?: (event?: SubmitEvent | undefined) => Promise<void> | void;
onChange?: FormChangeHandler;
}
Expand All @@ -32,7 +31,6 @@ export function useForm(options?: IOptions): IFormContext {
}

const disableEnterSubmit = options?.disableEnterSubmit ?? parentForm?.disableEnterSubmit ?? false;
const disableCtrlEnterSubmit = options?.disableCtrlEnterSubmit ?? parentForm?.disableCtrlEnterSubmit ?? false;

useExecutor({
executor: parentForm?.onChange,
Expand Down Expand Up @@ -84,7 +82,7 @@ export function useForm(options?: IOptions): IFormContext {
const isCtrlEnterSubmit =
event.key === 'Enter' &&
(event.ctrlKey || event.metaKey) &&
this.disableCtrlEnterSubmit === false &&
this.disableEnterSubmit === false &&
event.target instanceof HTMLTextAreaElement;
const isEnterSubmit = event.key === 'Enter' && this.disableEnterSubmit === false && event.target instanceof HTMLInputElement;

Expand Down Expand Up @@ -130,7 +128,7 @@ export function useForm(options?: IOptions): IFormContext {
}
},
}),
{ parent: parentForm, disableEnterSubmit, disableCtrlEnterSubmit },
{ parent: parentForm, disableEnterSubmit },
['setRef', 'change', 'keyDown', 'submit', 'validate'],
);

Expand Down

0 comments on commit 23d56c8

Please sign in to comment.