Skip to content

Commit

Permalink
feat(#1593): add new key emittedByClick in ifxChange event object in …
Browse files Browse the repository at this point in the history
…stepper
  • Loading branch information
akashyeole committed Nov 19, 2024
1 parent 6a27628 commit 20f325e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
12 changes: 7 additions & 5 deletions examples/wrapper-components/react-vite-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/components/src/components/stepper/interfaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export interface StepperState {
showStepNumber: boolean;
variant: 'default' | 'compact';

setActiveStep?(stepId: number): null;
setActiveStep?(stepId: number, setByClick: boolean): null;
}

4 changes: 2 additions & 2 deletions packages/components/src/components/stepper/step/step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ export class Step {

handleStepClick() {
if (!this.disabled && this.stepperState.variant === 'default' && (this.clickable || this.complete)) {
this.stepperState.setActiveStep(this.stepId)
this.stepperState.setActiveStep(this.stepId, true)
}
}

handleStepKeyDown(event: KeyboardEvent) {
if (!this.disabled && this.stepperState.variant === 'default' && (this.clickable || this.complete) && event.key === 'Enter') {
this.stepperState.setActiveStep(this.stepId)
this.stepperState.setActiveStep(this.stepId, true)
}
}

Expand Down
11 changes: 8 additions & 3 deletions packages/components/src/components/stepper/stepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class Stepper {

@State() stepsCount: number;
@State() shouldEmitEvent: boolean = true;
@State() emittedByClick: boolean = false;

@Listen('ifxChange')
onStepChange(event: CustomEvent) {
Expand Down Expand Up @@ -77,11 +78,14 @@ export class Stepper {
}
}
}

emitIfxChange(activeStep: number, previousActiveStep: number) {
this.ifxChange.emit({activeStep: activeStep,
previousActiveStep: previousActiveStep,
totalSteps: this.stepsCount });
totalSteps: this.stepsCount,
emittedByClick: this.emittedByClick
});
this.emittedByClick = false;
}

getSteps() {
Expand All @@ -100,7 +104,8 @@ export class Stepper {
}


setActiveStep(stepId: number) {
setActiveStep(stepId: number, setByClick: boolean = false) {
this.emittedByClick = setByClick;
this.activeStep = stepId;
}

Expand Down

0 comments on commit 20f325e

Please sign in to comment.