Skip to content

Commit

Permalink
fix(elements): 🐛 fix isHidden to account for parent tile
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNZL committed Jul 20, 2022
1 parent f85b90d commit dcc2ccd
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/elements/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class Element {
element.id = id;

this.element = element;
this.tile = Element.findParentTile(element);
}

public static getInstance<T extends string>({ id, type, element }: {
Expand Down Expand Up @@ -71,7 +72,7 @@ export class Element {
}

public get isHidden() {
return this.element.classList.contains('hidden');
return this.element.classList.contains('hidden') || (this.tile && this.tile.classList.contains('hidden'));
}

private parseHeadingLevel(tagName: string) {
Expand Down Expand Up @@ -112,8 +113,6 @@ export class Element {
this.element.parentElement.classList.remove('hidden');
}

this.tile ??= Element.findParentTile(this.element.parentElement);

if (!this.tile || !Element.isSomeChildShown(this.tile)) return;

this.tile.classList.remove('hidden');
Expand All @@ -139,8 +138,6 @@ export class Element {
this.element.parentElement.classList.add('hidden');
}

this.tile ??= Element.findParentTile(this.element.parentElement);

if (!this.tile || !Element.isEveryChildHidden(this.tile)) return;

this.tile.classList.add('hidden');
Expand Down

0 comments on commit dcc2ccd

Please sign in to comment.