Skip to content

Commit b4b6466

Browse files
committed
refactor(danger-button): update progress handling logic to use resetProgress method
Replace stopProgress method with resetProgress to streamline progress bar management. This change enhances event handling for mouse and touch interactions, ensuring consistent behavior across different input types.
1 parent 8ef7748 commit b4b6466

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

app/components/danger-button-with-timed-confirmation.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
class="relative border-0 overflow-hidden"
33
{{! template-lint-disable no-pointer-down-event-binding }}
44
{{on "mousedown" this.startProgress}}
5-
{{on "mouseleave" this.stopProgress}}
6-
{{on "mouseup" this.stopProgress}}
5+
{{on "mouseleave" this.resetProgress}}
6+
{{on "mouseup" this.resetProgress}}
77
{{on "touchstart" this.startProgress}}
8-
{{on "touchcancel" this.stopProgress}}
9-
{{on "touchend" this.stopProgress}}
8+
{{on "touchcancel" this.resetProgress}}
9+
{{on "touchend" this.resetProgress}}
1010
...attributes
1111
>
1212
{{yield}}

app/components/danger-button-with-timed-confirmation.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@ export default class DangerButtonWithTimedConfirmation extends Component<Signatu
2626
return htmlSafe(`width: ${this.progressWidth}%`);
2727
}
2828

29+
@action
30+
resetProgress() {
31+
this.shouldShowProgressBar = false;
32+
this.progressWidth = 0;
33+
clearInterval(this.progressInterval);
34+
}
35+
2936
@action
3037
startProgress(event: Event) {
3138
event.preventDefault(); // Prevent menu from popping up, which triggers touchend
32-
this.stopProgress();
39+
this.resetProgress();
3340

3441
this.shouldShowProgressBar = true;
3542
const intervalDelay = config.environment === 'test' ? 1 : 30;
@@ -45,13 +52,6 @@ export default class DangerButtonWithTimedConfirmation extends Component<Signatu
4552
}
4653
}, intervalDelay);
4754
}
48-
49-
@action
50-
stopProgress() {
51-
this.shouldShowProgressBar = false;
52-
this.progressWidth = 0;
53-
clearInterval(this.progressInterval);
54-
}
5555
}
5656

5757
declare module '@glint/environment-ember-loose/registry' {

0 commit comments

Comments
 (0)