Update CloneController - added/cleared events should not be cancelable

- While no code uses the event.preventDefault on these it's good practice to advise when cancelling will do nothing
pull/12515/head
LB 2024-10-31 15:45:41 +10:00 zatwierdzone przez LB (Ben Johnston)
rodzic b903b572d9
commit 93384a062e
1 zmienionych plików z 2 dodań i 2 usunięć
client/src/controllers

Wyświetl plik

@ -106,7 +106,7 @@ export class CloneController extends Controller<HTMLElement> {
debounce(() => {
this.element.classList.remove(...this.hideClasses);
this.element.classList.add(...this.showClasses);
this.dispatch('added');
this.dispatch('added', { cancelable: false });
}, this.showDelayValue || null /* run immediately if zero */)().then(() => {
// Once complete, check if we should automatically clear the content after a delay
const autoClearValue = this.autoClearValue || null;
@ -141,7 +141,7 @@ export class CloneController extends Controller<HTMLElement> {
debounce(noop, clearDelayValue)().then(() => {
if (!this?.isClearing) return;
this.containerTarget.innerHTML = '';
this.dispatch('cleared');
this.dispatch('cleared', { cancelable: false });
this.isClearing = false;
});
}