Skip to content

Commit

Permalink
fix(tooltip): fixing content display issues before upgraded (#1323)
Browse files Browse the repository at this point in the history
* fix(tooltip): making content display non until floating-ui upgrades content

* fix(tooltip): moving initialized below #float
  • Loading branch information
brianferry authored Nov 17, 2023
1 parent c03a896 commit eefc04c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-onions-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rhds/elements": patch
---

`<rh-tooltip>`: fixes issue where content would take up unwanted space before the element fully upgraded
4 changes: 4 additions & 0 deletions elements/rh-tooltip/rh-tooltip.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
);
}

:not(.initialized) #tooltip {
display: none;
}

#tooltip:after {
display: block;
content: "";
Expand Down
4 changes: 4 additions & 0 deletions elements/rh-tooltip/rh-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export class RhTooltip extends LitElement {
content: (): HTMLElement | undefined | null => this.shadowRoot?.querySelector('#tooltip'),
});

#initialized = false;

override connectedCallback(): void {
super.connectedCallback();
ENTER_EVENTS.forEach(evt => this.addEventListener(evt, this.show));
Expand All @@ -70,6 +72,7 @@ export class RhTooltip extends LitElement {
<div id="container"
style="${styleMap(styles)}"
class="${classMap({ open,
'initialized': !!this.#initialized,
[on]: !!on,
[anchor]: !!anchor,
[alignment]: !!alignment })}">
Expand All @@ -89,6 +92,7 @@ export class RhTooltip extends LitElement {
!placement?.match(/top|bottom/) ? 15
: { mainAxis: 15, alignmentAxis: -4 };
await this.#float.show({ offset, placement });
this.#initialized = true;
}

/** Hide the tooltip */
Expand Down

0 comments on commit eefc04c

Please sign in to comment.