Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/modal missing close event #598

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/uui-modal/lib/uui-modal.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export class UUIModalElement extends LitElement {

private _transitionDuration = 250;

@property()
@property({ type: Number, attribute: 'transition-duration' })
public get transitionDuration() {
return this._transitionDuration;
}
public set transitionDuration(value) {
public set transitionDuration(value: number) {
this._transitionDuration = value;
this.style.setProperty(
'--uui-modal-transition-duration',
Expand All @@ -45,7 +45,6 @@ export class UUIModalElement extends LitElement {
event?.stopImmediatePropagation();

const openEvent = new CustomEvent('open', {
bubbles: true,
cancelable: true,
});

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

const closeEvent = new CustomEvent('close', {
bubbles: true,
cancelable: true,
});
this.dispatchEvent(closeEvent);
Expand All @@ -80,6 +78,9 @@ export class UUIModalElement extends LitElement {
this.isClosing = true;
this.isOpen = false;
this._dialogElement?.close();

this.dispatchEvent(new CustomEvent('close-end'));

this.remove();
}

Expand Down
4 changes: 4 additions & 0 deletions packages/uui-modal/lib/uui-modal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ Dispatched on first render. This will set open to true and show the modal. Can b
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.
This is used in the `uui-modal-sidebar` to wait for the animation to finish before removing the modal from the DOM.

#### `close-end`

This event is triggered before removing the component from the DOM, either after animations or delays or when `_closeModal()` is manually invoked.

### CSS Variables

---
Expand Down
Loading