Keep hint layer unstyled by page popover rules

This commit is contained in:
Kamran Ahmed
2026-10-29 01:19:30 +00:00
parent 1c77160392
commit e370639215
3 changed files with 44 additions and 13 deletions
@@ -10,6 +10,12 @@ ships, these entries move under a versioned heading.
## Unreleased
### Fixed
- Hints in an open `<dialog>` no longer get covered when the page styles
every `[popover]`, for example with a dark background.
([#628](https://github.com/nilbuild/driver.js/issues/628))
## 1.10.2
### Fixed
+16 -13
View File
@@ -4,19 +4,22 @@
classes) out of here. */
.driver-layer {
position: fixed;
inset: 0;
width: auto;
height: auto;
max-width: none;
max-height: none;
margin: 0;
padding: 0;
border: 0;
background: transparent;
color: inherit;
overflow: visible;
pointer-events: none;
position: fixed !important;
top: 0 !important;
right: 0 !important;
bottom: 0 !important;
left: 0 !important;
width: auto !important;
height: auto !important;
max-width: none !important;
max-height: none !important;
margin: 0 !important;
padding: 0 !important;
border: 0 !important;
background: transparent !important;
color: inherit !important;
overflow: visible !important;
pointer-events: none !important;
}
.driver-layer::backdrop {
+22
View File
@@ -1,3 +1,5 @@
import { readFileSync } from "fs";
import { resolve } from "path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { driver, type Driver } from "../src/driver";
import { hints, type DriverHint, type Hints } from "../src/hints";
@@ -1018,6 +1020,26 @@ describe("modal dialogs", () => {
expect(dialog.querySelectorAll(".driver-layer")).toHaveLength(1);
});
it("keeps the host unstyled when the page styles every popover", () => {
const style = document.createElement("style");
style.textContent = `${readFileSync(resolve(process.cwd(), "src/popover.css"), "utf8")}
html [popover] { background-color: rgb(1, 2, 3); padding: 12px; top: 40px; }`;
document.head.appendChild(style);
document.body.insertAdjacentHTML("beforeend", DIALOG_HTML);
const h = createHints({ hints: [DIALOG_HINT] });
h.show();
const layer = document.querySelector(".driver-layer")!;
const computed = getComputedStyle(layer);
expect(computed.backgroundColor).toBe("rgba(0, 0, 0, 0)");
expect(computed.paddingTop).toBe("0px");
expect(computed.top).toBe("0px");
h.hide();
style.remove();
});
it("removes the host once its UI is gone", () => {
document.body.insertAdjacentHTML("beforeend", DIALOG_HTML);
const dialog = document.querySelector("dialog")!;