Skip to content

Commit 825d722

Browse files
fix: Modal close-end event, no more bubbling modal events (#598)
Co-authored-by: Niels Lyngsø <[email protected]>
1 parent 6575986 commit 825d722

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/uui-modal/lib/uui-modal.element.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ export class UUIModalElement extends LitElement {
1818

1919
private _transitionDuration = 250;
2020

21-
@property()
21+
@property({ type: Number, attribute: 'transition-duration' })
2222
public get transitionDuration() {
2323
return this._transitionDuration;
2424
}
25-
public set transitionDuration(value) {
25+
public set transitionDuration(value: number) {
2626
this._transitionDuration = value;
2727
this.style.setProperty(
2828
'--uui-modal-transition-duration',
@@ -45,7 +45,6 @@ export class UUIModalElement extends LitElement {
4545
event?.stopImmediatePropagation();
4646

4747
const openEvent = new CustomEvent('open', {
48-
bubbles: true,
4948
cancelable: true,
5049
});
5150

@@ -60,7 +59,6 @@ export class UUIModalElement extends LitElement {
6059
event?.stopImmediatePropagation();
6160

6261
const closeEvent = new CustomEvent('close', {
63-
bubbles: true,
6462
cancelable: true,
6563
});
6664
this.dispatchEvent(closeEvent);
@@ -80,6 +78,9 @@ export class UUIModalElement extends LitElement {
8078
this.isClosing = true;
8179
this.isOpen = false;
8280
this._dialogElement?.close();
81+
82+
this.dispatchEvent(new CustomEvent('close-end'));
83+
8384
this.remove();
8485
}
8586

packages/uui-modal/lib/uui-modal.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ Dispatched on first render. This will set open to true and show the modal. Can b
9191
Dispatched when the modal is closed. Can be cancelled if you want to prevent the modal from closing. But then you'll have to manually call `_closeModal()` when you want to close the modal.
9292
This is used in the `uui-modal-sidebar` to wait for the animation to finish before removing the modal from the DOM.
9393

94+
#### `close-end`
95+
96+
This event is triggered before removing the component from the DOM, either after animations or delays or when `_closeModal()` is manually invoked.
97+
9498
### CSS Variables
9599

96100
---

0 commit comments

Comments
 (0)