Skip to content

fix: Omit the popover source when the trigger is not an HTML element - #7227

Merged
imdreamrunner merged 1 commit into
meta:mainfrom
rapsealk:fix/tooltip-svg-trigger-source
Oct 16, 2026
Merged

imdreamrunner merged 1 commit into
meta:mainfrom
rapsealk:fix/tooltip-svg-trigger-source

Conversation

@rapsealk

@rapsealk rapsealk commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

User impact

A Tooltip whose 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 receives aria-describedby, so assistive technology keeps the hint, but nothing appears for a pointer or keyboard user, and each attempt to open it throws an uncaught TypeError. Restoring it brings icon-only hints back with no API change for a consumer.

Problem and solution fit

Why it occurs. useLayer hands its trigger to showPopover as the invoker source. ShowPopoverOptions.source is declared as an HTMLElement, so the value goes through WebIDL conversion, and a caller-rendered icon is an SVGElement, which fails that conversion and throws. Tooltip renders its trigger inside a display: contents wrapper and reads it back as wrapper.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" to Layer/useLayer.tsx, so passing what the platform accepts is owned here; no claim in that record requires source to be passed for every trigger. spec:AST-055 FR1 — a caller-supplied control MUST NOT be required to be a particular tag — is the supporting intent: an SVGElement is a legitimate caller-rendered trigger. spec:AST-013 FR10 governs the evidence below, because this changes a native Popover call.

Smallest restoration

Pass source only when the trigger is an HTMLElement. One guard at the only site that passes source (Layer/useLayer.tsx:771); the hide path and every other showPopover() 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:

    const pop = document.querySelector('[popover]');
    pop.showPopover({source: document.querySelector('svg')});
    // TypeError: Failed to execute 'showPopover' on 'HTMLElement':
    //   Failed to read the 'source' property from 'ShowPopoverOptions':
    //   Failed to convert value to 'HTMLElement'.
    pop.matches(':popover-open'); // false

    In a consuming product SPA (lablup/backend.ai-fasttrack), every icon-only tooltip trigger on a job-detail page reported :popover-open === false and 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.

    pop.showPopover(); // no source
    pop.matches(':popover-open');                      // true
    pop.getBoundingClientRect().top >=
      document.querySelector('svg').getBoundingClientRect().bottom; // true
  • Representative unchanged path: an HTML trigger still passes the element — useLayer.test.tsx asserts showPopover is 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 source asserts source is absent while the icon keeps the layer's aria-describedby. Removing the guard is the only change needed to fail it, and it is then the only failing test in the file.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

In a clean worktree of this branch:

node node_modules/vitest/vitest.mjs run \
  packages/core/src/Tooltip/Tooltip.test.tsx \
  packages/core/src/Layer/useLayer.test.tsx              # 93 passed
node node_modules/typescript/bin/tsc \
  --project packages/core/tsconfig.json --noEmit         # clean
node scripts/check-changesets.mjs                        # clean
node scripts/check-sync.js                               # clean
node node_modules/eslint/bin/eslint.js <changed files>   # clean
node node_modules/prettier/bin/prettier.cjs --check <changed files>   # clean

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

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
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 9, 2026 3:55am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 9, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Oct 9, 2026
@astracat-bot

astracat-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 9, 2026, 5:18 AM UTC

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Tooltip (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 544 -
Complexity N/A Very High (56) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

22 of 442 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,229
Chat With Attachments probe dark 11,065
TableRowExpansion Detail Panel neutral dark 5,129
TableRowExpansion Detail Panel neutral light 4,050
TableGroupedRows Default neutral light 2,133
TableGroupedRows Default neutral dark 2,116
Markdown Default probe dark 897
Markdown Default probe light 897
Markdown Default neutral dark 882
Markdown Default neutral light 858

and 2 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

vjeux added a commit to vjeux/astryx that referenced this pull request Oct 12, 2026
…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.
@imdreamrunner
imdreamrunner enabled auto-merge (squash) October 16, 2026 04:14
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Oct 16, 2026
@imdreamrunner
imdreamrunner merged commit 3f45fc2 into meta:main Oct 16, 2026
39 of 40 checks passed
@rapsealk
rapsealk deleted the fix/tooltip-svg-trigger-source branch October 16, 2026 09:22

This branch was successfully deployed

1 active deployment
Preview — bc5b1747 Deployed Oct 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Tooltip never opens when its child is an SVG icon (showPopover source TypeError)

3 participants