1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Remove debounce to fix test

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-12-01 13:16:02 -05:00
parent 3908141d35
commit 096d314353

View File

@ -10,7 +10,6 @@ import { Button } from "../button";
import { Stepper } from "../stepper"; import { Stepper } from "../stepper";
import { SubTitle } from "../layout/sub-title"; import { SubTitle } from "../layout/sub-title";
import { Spinner } from "../spinner"; import { Spinner } from "../spinner";
import { debounce } from "lodash";
export interface WizardCommonProps<D> { export interface WizardCommonProps<D> {
data?: Partial<D>; data?: Partial<D>;
@ -79,10 +78,18 @@ export class Wizard<D> extends React.Component<WizardProps<D>, State> {
isFirstStep = () => this.step === 1; isFirstStep = () => this.step === 1;
isLastStep = () => this.step === this.steps.length; isLastStep = () => this.step === this.steps.length;
firstStep = (): any => this.step = 1; firstStep = () => {
nextStep = (): any => this.step++; this.step = 1;
prevStep = (): any => this.step--; };
lastStep = (): any => this.step = this.steps.length; nextStep = () => {
this.step++;
};
prevStep = () => {
this.step--;
};
lastStep = () => {
this.step = this.steps.length;
};
render() { render() {
const { className, title, header, hideSteps } = this.props; const { className, title, header, hideSteps } = this.props;
@ -180,9 +187,7 @@ export class WizardStep<D> extends React.Component<WizardStepProps<D>, WizardSte
} }
}; };
//because submit MIGHT be called through pressing enter, it might be fired twice. submit = () => {
//we'll debounce it to ensure it isn't
submit = debounce(() => {
if (!this.form) { if (!this.form) {
return; return;
} }
@ -190,9 +195,7 @@ export class WizardStep<D> extends React.Component<WizardStepProps<D>, WizardSte
if (this.form.noValidate || this.form.checkValidity()) { if (this.form.noValidate || this.form.checkValidity()) {
this.next(); this.next();
} }
}, 100, { };
leading: true,
});
renderLoading() { renderLoading() {
return ( return (
@ -202,17 +205,6 @@ export class WizardStep<D> extends React.Component<WizardStepProps<D>, WizardSte
); );
} }
//make sure we call submit if the "enter" keypress doesn't trigger the events
keyDown(evt: React.KeyboardEvent<HTMLElement>) {
if (evt.shiftKey || evt.metaKey || evt.altKey || evt.ctrlKey || evt.repeat) {
return;
}
if(evt.key === "Enter"){
this.submit();
}
}
render() { render() {
const { const {
step, isFirst, isLast, children, step, isFirst, isLast, children,
@ -230,7 +222,6 @@ export class WizardStep<D> extends React.Component<WizardStepProps<D>, WizardSte
className={cssNames(`WizardStep step${step}`, className)} className={cssNames(`WizardStep step${step}`, className)}
onSubmit={prevDefault(this.submit)} onSubmit={prevDefault(this.submit)}
noValidate={noValidate} noValidate={noValidate}
onKeyDown={(evt) => this.keyDown(evt)}
ref={e => this.form = e} ref={e => this.form = e}
> >
{beforeContent} {beforeContent}