Skip to content

Commit

Permalink
fix(modal): resolve an issue that is causing the modal to not correct…
Browse files Browse the repository at this point in the history
…ly set its height when the modal is open in the first render
  • Loading branch information
mimshins committed Dec 30, 2024
1 parent 8c225f9 commit fc8eac4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/web-components/src/modal/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,22 @@ export class Modal extends LitElement {
public set open(openState: boolean) {
if (openState === this._open) return;

this._open = openState;
const initialOpenState = !this.hasUpdated && openState && !this._open;

void this._toggleOpenState(openState);
const toggle = () => {
this._open = openState;

void this._toggleOpenState(openState);
};

if (initialOpenState) {
runAfterRepaint(() => {
const prevOpen = this._open;

toggle();
this.requestUpdate("open", prevOpen);
});
} else toggle();
}

public get open() {
Expand Down

0 comments on commit fc8eac4

Please sign in to comment.