Update SlAlert to check if countdownElement is defined before use - Fix #2450

pull/2456/head
Cameron 2025-06-07 16:47:50 +08:00
rodzic fb59fda70e
commit 3b4cfc9888
1 zmienionych plików z 8 dodań i 4 usunięć

Wyświetl plik

@ -95,7 +95,11 @@ export default class SlAlert extends ShoelaceElement {
this.base.hidden = !this.open;
}
private restartAutoHide() {
private async restartAutoHide() {
const { countdownElement } = this;
if (!countdownElement) {
await this.updateComplete;
}
this.handleCountdownChange();
clearTimeout(this.autoHideTimeout);
clearInterval(this.remainingTimeInterval);
@ -147,7 +151,7 @@ export default class SlAlert extends ShoelaceElement {
this.emit('sl-show');
if (this.duration < Infinity) {
this.restartAutoHide();
await this.restartAutoHide();
}
await stopAnimations(this.base);
@ -174,8 +178,8 @@ export default class SlAlert extends ShoelaceElement {
}
@watch('duration')
handleDurationChange() {
this.restartAutoHide();
async handleDurationChange() {
await this.restartAutoHide();
}
/** Shows the alert. */