Skip to content

Commit

Permalink
fix(tooltip): Prevent tooltip from appearing above modal overlay. #5388
Browse files Browse the repository at this point in the history
  • Loading branch information
driskull committed Dec 1, 2022
1 parent 3ed53e7 commit 071f161
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/assets/styles/_floating-ui.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ $floating-ui-transform-bottom: translateY(-5px);
$floating-ui-transform-top: translateY(5px);
$floating-ui-transform-left: translateX(5px);
$floating-ui-transform-right: translateX(-5px);
$floating-ui-default-z-index: 900;

:root {
--calcite-floating-ui-transition: var(--calcite-animation-timing);
--calcite-floating-ui-z-index: theme("zIndex.popover");
}

@mixin floatingUIAnim {
Expand Down Expand Up @@ -74,10 +74,10 @@ $floating-ui-default-z-index: 900;
}
}

@mixin floatingUIContainer($zIndex: $floating-ui-default-z-index) {
@mixin floatingUIContainer() {
display: block;
position: absolute;
z-index: $zIndex;
z-index: var(--calcite-floating-ui-z-index);
}

@mixin floatingUIWrapper {
Expand All @@ -88,9 +88,9 @@ $floating-ui-default-z-index: 900;
visibility: visible;
}

@mixin floatingUIHost($zIndex: $floating-ui-default-z-index) {
@mixin floatingUIHost() {
:host {
@include floatingUIContainer($zIndex);
@include floatingUIContainer();
}

@include floatingUIHostAnim();
Expand Down
1 change: 1 addition & 0 deletions src/components/combobox/combobox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
}

.floating-ui-container {
--calcite-floating-ui-z-index: theme("zIndex.dropdown");
@include floatingUIContainer();
@include floatingUIWrapper();
}
Expand Down
1 change: 1 addition & 0 deletions src/components/dropdown/dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@include disabled();

:host .calcite-dropdown-wrapper {
--calcite-floating-ui-z-index: theme("zIndex.dropdown");
@include floatingUIContainer();
@include floatingUIWrapper();
}
Expand Down
1 change: 1 addition & 0 deletions src/components/input-date-picker/input-date-picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
}

.menu-container {
--calcite-floating-ui-z-index: theme("zIndex.dropdown");
@include floatingUIContainer();
@include floatingUIWrapper();
@apply invisible;
Expand Down
4 changes: 2 additions & 2 deletions src/components/popover/popover.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("calcite-popover", () => {
);
});

it("should have zIndex of 900", async () => {
it("should have zIndex of 700", async () => {
const page = await newE2EPage();

await page.setContent(
Expand All @@ -28,7 +28,7 @@ describe("calcite-popover", () => {

const style = await popover.getComputedStyle();

expect(style.zIndex).toBe("900");
expect(style.zIndex).toBe("700");
});

it("is accessible when closed", async () =>
Expand Down
4 changes: 4 additions & 0 deletions src/components/popover/popover.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
:host {
--calcite-floating-ui-z-index: theme("zIndex.popover");
}

@include floatingUIHost();
@include floatingUIArrow();

Expand Down
4 changes: 2 additions & 2 deletions src/components/tooltip/tooltip.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("calcite-tooltip", () => {
}
]));

it("should have zIndex of 999", async () => {
it("should have zIndex of 701", async () => {
const page = await newE2EPage();

await page.setContent(
Expand All @@ -62,7 +62,7 @@ describe("calcite-tooltip", () => {

const style = await tooltip.getComputedStyle();

expect(style.zIndex).toBe("999");
expect(style.zIndex).toBe("701");
});

it("tooltip positions when referenceElement is set", async () => {
Expand Down
6 changes: 5 additions & 1 deletion src/components/tooltip/tooltip.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
@include floatingUIHost(999);
:host {
--calcite-floating-ui-z-index: theme("zIndex.tooltip");
}

@include floatingUIHost();
@include floatingUIArrow();

.container {
Expand Down
7 changes: 4 additions & 3 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,10 @@ export default {
header: "400",
toast: "500",
dropdown: "600",
overlay: "700",
modal: "800",
popup: "900"
popover: "700",
tooltip: "701",
overlay: "800",
modal: "900"
}
}
},
Expand Down

0 comments on commit 071f161

Please sign in to comment.