Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(ui): let tooltips ignore fields of closed menus

Bernhard Jackiewicz57090cbd2e85
diff --git a/graph-ui/src/ui/tooltip/Hint.test.tsx b/graph-ui/src/ui/tooltip/Hint.test.tsx
index 0615c0559..4302172cd 100644
--- a/graph-ui/src/ui/tooltip/Hint.test.tsx
+++ b/graph-ui/src/ui/tooltip/Hint.test.tsx
@@ -137,6 +137,45 @@ describe('Hint', () => {
* passiert ist. An den Schaltern dieser Oberflaeche ist er dann obendrein
* falsch, weil ihre Beschriftung mit dem Zustand kippt.
*/
+ /*
+ * Handtest 2026-10-04 (G3): der Kasten an "Expand +1" stand rechts neben
+ * dem Knopf und ragte in den Kopf der Seite, obwohl unter ihm Platz war.
+ * Geschuetzt waren die Eingabefelder der zugeklappten Menues daneben
+ * ("Path to…", "Edge types"): ihr Inhalt ist nicht gezeichnet, hatte im
+ * Browser aber weiter einen Kasten. Geschuetzt ist nur, was zu sehen ist.
+ */
+ it('weicht keinem Feld aus, das in einem zugeklappten details gar nicht gezeichnet ist', async () => {
+ const rect = (x: number, y: number, width: number, height: number) => () =>
+ ({ x, y, width, height, left: x, top: y, right: x + width, bottom: y + height, toJSON: () => ({}) }) as DOMRect;
+ const size = vi.spyOn(HTMLElement.prototype, 'offsetWidth', 'get').mockImplementation(function (this: HTMLElement) {
+ return this.dataset.testid === 'atlas-hint' ? 200 : 0;
+ });
+ const height = vi.spyOn(HTMLElement.prototype, 'offsetHeight', 'get').mockImplementation(function (this: HTMLElement) {
+ return this.dataset.testid === 'atlas-hint' ? 40 : 0;
+ });
+ await render(
+ <div>
+ <Hint name="probe" text="what this does"><button type="button">go</button></Hint>
+ <details><summary>menu</summary><input aria-label="field in the menu" /></details>
+ </div>,
+ );
+ trigger().getBoundingClientRect = rect(100, 100, 80, 24);
+ // Right under the trigger, where the box goes first: the field of the closed menu.
+ const field = container.querySelector('input')!;
+ field.getBoundingClientRect = rect(100, 130, 300, 30);
+ const hover = async () => {
+ await act(async () => { trigger().dispatchEvent(new MouseEvent('mouseover', { bubbles: true })); });
+ const side = tooltip()?.getAttribute('data-side');
+ await act(async () => { trigger().dispatchEvent(new MouseEvent('mouseout', { bubbles: true })); });
+ return side;
+ };
+ expect(await hover()).toBe('below');
+ // Open, the field is drawn and protected again: the box goes above.
+ container.querySelector('details')!.open = true;
+ expect(await hover()).toBe('above');
+ size.mockRestore(); height.mockRestore();
+ });
+
it('schliesst sich, sobald der Ausloeser gedrueckt wurde', async () => {
await render(<Hint name="probe" text="what this does"><button type="button">go</button></Hint>);
await act(async () => {
diff --git a/graph-ui/src/ui/tooltip/Hint.tsx b/graph-ui/src/ui/tooltip/Hint.tsx
index e1cf65ca1..4f2f2637a 100644
--- a/graph-ui/src/ui/tooltip/Hint.tsx
+++ b/graph-ui/src/ui/tooltip/Hint.tsx
@@ -113,11 +113,29 @@ export interface HintProps {
children: ReactElement | ((hold: HintHold) => ReactElement);
}
+/*
+ * Ob ein Element ueberhaupt gezeichnet ist.
+ *
+ * Handtest 2026-10-04 (G3): der Inhalt eines zugeklappten `<details>` ist
+ * nicht zu sehen, behaelt im Browser aber einen Kasten (die Menues "Path to…"
+ * und "Edge types" der Galaxie mit ihren Feldern). Als geschuetzt gezaehlt,
+ * schoben sie den Kasten von "Expand +1" vom Platz unter dem Knopf in den Kopf
+ * der Seite. `checkVisibility` sagt es im Browser fuer jeden Grund; die Regel
+ * fuer `<details>` gilt auch dort, wo es die Methode nicht gibt.
+ */
+function rendered(node: Element): boolean {
+ const closed = node.closest('details:not([open])');
+ if (closed !== null && !(closed.querySelector(':scope > summary')?.contains(node) ?? false)) {
+ return false;
+ }
+ return typeof node.checkVisibility !== 'function' || node.checkVisibility();
+}
+
/** Die Rechtecke, die an dieser Stelle nicht verdeckt werden duerfen. */
function protectedRects(anchor: Element): HintRect[] {
const out: HintRect[] = [];
for (const node of document.querySelectorAll(HINT_PROTECTED_SELECTOR)) {
- if (node === anchor) {
+ if (node === anchor || !rendered(node)) {
continue;
}
const style = window.getComputedStyle(node);
diff --git a/graph-ui/tools/lib/readability.mjs b/graph-ui/tools/lib/readability.mjs
index 81ef44dcd..e442d215e 100644
--- a/graph-ui/tools/lib/readability.mjs
+++ b/graph-ui/tools/lib/readability.mjs
@@ -811,6 +811,12 @@ export async function tooltipCover(page, index) {
if (node === box || box.contains(node) || node.contains(box)) {
continue;
}
+ // Dieselbe Regel wie `rendered` in src/ui/tooltip/Hint.tsx: der Inhalt eines zugeklappten <details> ist nicht zu sehen.
+ const closed = node.closest('details:not([open])');
+ if ((closed !== null && !(closed.querySelector(':scope > summary')?.contains(node) ?? false))
+ || (typeof node.checkVisibility === 'function' && !node.checkVisibility())) {
+ continue;
+ }
const other = node.getBoundingClientRect();
if (other.width <= 0 || other.height <= 0) {
continue;