Skip to content

Commit

Permalink
fix(modal): forcing watcher trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
manoncarbonnel authored and dpellier committed Oct 11, 2023
1 parent 32b44fc commit f71d16d
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,20 @@ export class OsdsModal implements OdsModalAttribute, OdsModalMethod {
@Method()
async open(): Promise<void> {
this.masked = false;
this.inertBodyChildren(this.masked);
}

@Watch('masked')
watchOpenedStateHandler(masked: boolean) {
this.inertBodyChildren(masked);
}

inertBodyChildren(masked: boolean = false) {
inertBodyChildren(masked = false) {
const directChildren = Array.from(document.body.children);
for (const child of directChildren) {
if (child !== this.el && child.nodeName !== 'SCRIPT') {
if (!masked && !child.getAttribute('inert')) {
if (!masked) {
child.setAttribute('inert', '');
} else if (child.getAttribute('inert')) {
} else {
child.removeAttribute('inert');
}
}
Expand All @@ -66,6 +65,7 @@ export class OsdsModal implements OdsModalAttribute, OdsModalMethod {

componentWillLoad(): void {
document.body.appendChild(this.el);
this.watchOpenedStateHandler(this.masked ?? false);
}

render() {
Expand Down

0 comments on commit f71d16d

Please sign in to comment.