mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
[Toolbar] Fix tooltip overlap bug (#9283)
This commit is contained in:
parent
feaba2c7fc
commit
7a231e4763
2 changed files with 5 additions and 1 deletions
|
@ -57,9 +57,12 @@ export function attachTooltipToHighlight(
|
|||
originalElement: Element
|
||||
) {
|
||||
highlight.shadowRoot.append(tooltip);
|
||||
// Track the original z-index so that we can restore it after hover
|
||||
const originalZIndex = highlight.style.zIndex;
|
||||
|
||||
(['mouseover', 'focus'] as const).forEach((event) => {
|
||||
highlight.addEventListener(event, () => {
|
||||
highlight.style.zIndex = '9999999999';
|
||||
tooltip.dataset.show = 'true';
|
||||
const originalRect = originalElement.getBoundingClientRect();
|
||||
const dialogRect = tooltip.getBoundingClientRect();
|
||||
|
@ -77,6 +80,7 @@ export function attachTooltipToHighlight(
|
|||
(['mouseout', 'blur'] as const).forEach((event) => {
|
||||
highlight.addEventListener(event, () => {
|
||||
tooltip.dataset.show = 'false';
|
||||
highlight.style.zIndex = originalZIndex;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -80,7 +80,6 @@ export default {
|
|||
const rect = islandElement.getBoundingClientRect();
|
||||
const highlight = createHighlight(rect);
|
||||
const tooltip = buildIslandTooltip(island);
|
||||
attachTooltipToHighlight(highlight, tooltip, islandElement);
|
||||
|
||||
// Set the z-index to be 1 higher than the greatest z-index in the stack.
|
||||
// And also set the highlight/tooltip as being fixed position if they are inside
|
||||
|
@ -94,6 +93,7 @@ export default {
|
|||
tooltip.style.position = highlight.style.position = 'fixed';
|
||||
}
|
||||
|
||||
attachTooltipToHighlight(highlight, tooltip, islandElement);
|
||||
canvas.append(highlight);
|
||||
islandsOverlays.push({ highlightElement: highlight, island: islandElement });
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue