Repository navigation
fix: Omit the popover source when the trigger is not an HTML element - #7227
Conversation
A Tooltip whose child is a rendered icon never appeared. The layer passed its
trigger as `showPopover`'s invoker `source`, declared as an `HTMLElement`; a
caller-rendered icon is an `SVGElement`, whose dictionary conversion throws,
and the throw happens before the popover is shown — so the layer stayed shut
and every hover left an uncaught TypeError behind.
Pass `source` only when the trigger is an `HTMLElement`. Positioning still
reads the anchor-name pair, so an icon trigger keeps its placement and gives
up only the invoker's focus order.
The HTML path is unchanged, and its `{source: trigger}` assertion in
useLayer.test.tsx stays as the representative unchanged case.
Refs meta#7226
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Thanks for the focused restoration — this is ready to approve from this review.
The single guard at the layer's showPopover call is the smallest right fix: HTML triggers still receive the invoker source exactly as before, while an SVGElement icon now opens without the value its conversion rejects, keeping its existing aria-describedby wiring. I verified the new regression test together with the existing HTML-trigger assertion, and reproduced the underlying platform behaviour in a real Chromium: an SVG source throws and the popover stays closed, while omitting it opens.
No public API changes, and no follow-up is needed from this review.
[Automated review]
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsTooltip (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression22 of 442 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 2 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
…ument rule - useLayer: drop invokerSource and its two SVG-trigger cases. They change only SVG triggers, the defect meta#7227 fixes. The case that keeps an HTML trigger in another document as the source stays as a guard. - family:overlay-dismissal: FR8 and DEC-2, proposed and pending owner review. Each document ranks its own members, and the stack listens once in each document that holds one.
User impact
A
Tooltipwhose child is a rendered icon — the info glyph beside a label, or the whole trigger in a dense toolbar — never shows its hint. The trigger still receivesaria-describedby, so assistive technology keeps the hint, but nothing appears for a pointer or keyboard user, and each attempt to open it throws an uncaughtTypeError. Restoring it brings icon-only hints back with no API change for a consumer.Problem and solution fit
Why it occurs.
useLayerhands its trigger toshowPopoveras the invokersource.ShowPopoverOptions.sourceis declared as anHTMLElement, so the value goes through WebIDL conversion, and a caller-rendered icon is anSVGElement, which fails that conversion and throws.Tooltiprenders its trigger inside adisplay: contentswrapper and reads it back aswrapper.firstElementChild as HTMLElement(Tooltip/Tooltip.tsx:284), so an icon arrives at the layer with the cast — rather than the interface — intact.Why it harms the task. The throw happens inside the show path, before the layer records the popover as open, so the popover never shows and the layer's state never agrees with the DOM. A consumer cannot work around it locally: the failing call is the layer's, not the child they render.
Why that harm matters. An icon-only trigger is the shape used exactly where there is no visible label to fall back on — there, the hint is the only affordance there is.
Fit. The guard changes what one option is given, not whether the popover opens. An icon trigger keeps its anchor pairing and gives up only the invoker's focus order, which it did not have in a form the browser accepted anyway.
Expected behavior and authority
docs/architecture/layer-runtime.md(Owning code, line 425) assigns "trigger source" toLayer/useLayer.tsx, so passing what the platform accepts is owned here; no claim in that record requiressourceto be passed for every trigger.spec:AST-055FR1 — a caller-supplied control MUST NOT be required to be a particular tag — is the supporting intent: anSVGElementis a legitimate caller-rendered trigger.spec:AST-013FR10 governs the evidence below, because this changes a native Popover call.Smallest restoration
Pass
sourceonly when the trigger is anHTMLElement. One guard at the only site that passessource(Layer/useLayer.tsx:771); the hide path and every othershowPopover()call site take no options and are untouched. The comment at the site records why the option is dropped instead of the value being coerced.Evidence
Reproduction before the change: in Chromium 153 (macOS) the call fails and the popover stays shut:
In a consuming product SPA (lablup/backend.ai-fasttrack), every icon-only tooltip trigger on a job-detail page reported
:popover-open === falseand logged that error, while the HTML-triggered tooltips on the same page opened normally — the reason the defect was reported at all.Result after the change: the same call without the option opens and stays anchored below its trigger.
Representative unchanged path: an HTML trigger still passes the element —
useLayer.test.tsxassertsshowPopoveris called with{source: trigger}, and that assertion is untouched.Regression test or other mutation-sensitive proof:
Tooltip > icon-only trigger > opens an icon trigger without passing an SVGElement as the sourceassertssourceis absent while the icon keeps the layer'saria-describedby. Removing the guard is the only change needed to fail it, and it is then the only failing test in the file.Scope
Testing
In a clean worktree of this branch:
Real browser: Chromium 153 on macOS, against a local page holding an anchor-positioned popover — the two probes above, before and after. No named-engine claim is made: the failure is a WebIDL dictionary conversion, which every engine implementing the Popover API performs the same way, and the change does not touch the existing
typeof showPopover === 'function'fallback for browsers that lack it. The guard itself is deterministic state, so the component path is covered by the unit test rather than by pixels.Fixes #7226