diff --git a/lib/utils/z-index-map.ts b/lib/utils/z-index-map.ts index 51f211a..c52edfc 100644 --- a/lib/utils/z-index-map.ts +++ b/lib/utils/z-index-map.ts @@ -4,7 +4,10 @@ export const zIndexMap = { viewMenuIcon: 48, clickToInteractOverlay: 100, schematicComponentDetailsTooltip: 105, - schematicComponentHoverOutline: 47, - schematicPortHoverOutline: 48, + // Kept below viewMenuIcon (48): schematicPortHoverOutline + 1 (the port + // hover label's z-index, see SchematicPortMouseTarget) must also stay + // clear of every other layer. + schematicComponentHoverOutline: 45, + schematicPortHoverOutline: 46, schematicSearch: 101, } diff --git a/tests/z-index-map.test.ts b/tests/z-index-map.test.ts new file mode 100644 index 0000000..1121bde --- /dev/null +++ b/tests/z-index-map.test.ts @@ -0,0 +1,19 @@ +import { expect, test } from "bun:test" +import { zIndexMap } from "../lib/utils/z-index-map" + +test("all zIndexMap values are unique", () => { + const values = Object.values(zIndexMap) + expect(new Set(values).size).toBe(values.length) +}) + +test("the schematic port hover label doesn't collide with any other layer", () => { + // SchematicPortMouseTarget renders its hover label at + // schematicPortHoverOutline + 1, so that derived value needs to stay clear + // of every other layer too, not just the base value. + const portHoverLabelZIndex = zIndexMap.schematicPortHoverOutline + 1 + const otherValues = Object.entries(zIndexMap) + .filter(([key]) => key !== "schematicPortHoverOutline") + .map(([, value]) => value) + + expect(otherValues).not.toContain(portHoverLabelZIndex) +})