Repository navigation
feat(core): add XDSPopover component - #298
Conversation
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsLayer · View in Storybook · 🆕 XDSPopover
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
left a comment
There was a problem hiding this comment.
Some feedback on the implementation. Also the contents in the popovers in storybook still appear blank. May have to do with some styling but if we can't figure it out I'll debug it manually on my laptop.
|
Addressed all 6 review comments:
Also added explicit Net: -30 lines, simpler API (removed trigger, hasFocusTrap, initialIsShown; added anchorRef). |
|
Clicking the popovers trigger while the popovers is visible appears to retrigger opening the popover layer. |
|
The contents still appear black but I'll manually debug this tomorrow. |
|
On mobile it seems like the latter has a hard time staying in the viewport. I think it could make sense for the popovers to be start aligned with the trigger rather than center aligned and we should flip alignment if there's not enough space in view port. |
ad95f43 to
445c750
Compare
|
Round 2 fixes pushed (rebased on main including React 19 upgrade):
Re: React 19 and the controlled state sync — the remaining |
|
Had to manually debug, but this is looking better now |
|
The keyboard interactions don't seem to work in the examples. Likely this is due to the popover setting click interactions manually on child elements. It might be better to be more explicit about showing/hiding the popover via onClick interactions and then the |
4dd99cc to
f8cf948
Compare
🤖 Night Watch QA Report
|
9333208 to
0cf366f
Compare
❌ Visual Regression — FailedScreenshots differ from baselines for: XDSHoverCard, XDSTooltip, XDSPopover View diff artifacts to review the visual changes.
|
Adds XDSPopover — a general-purpose popover built on useXDSLayer. Features: - Anchored positioning with 12 placement options - Click-outside and Escape to dismiss - Focus management (auto-focus first focusable or heading) - Entry animation (fade + slide) - Default padding matching HoverCard - Accessible: role=dialog, aria-labelledby, focus trap Co-authored-by: Navi <[email protected]>
Replace placeholder divs with realistic content using XDSHeading, XDSText, XDSSwitch, XDSCheckboxInput, XDSDivider, etc. Stories now demonstrate real use cases: - Settings panel with toggles - Filter panel with checkboxes and apply/reset - Confirmation dialog with destructive action - Hover profile card - Keyboard shortcuts reference (above placement)
- Remove hover trigger — use XDSHoverCard for hover overlays - Remove hasFocusTrap prop — always enforce focus trapping - Remove initialIsShown prop — simplify to controlled/uncontrolled - Inline ClickPopover — no separate component needed - Add anchorRef support — sibling-mode rendering (matches XDSTooltip) - Simplify click handler — delegate to hook's toggle() - Add explicit color to container — ensure text visibility in top layer - Remove XDSPopoverTrigger type export - Update stories: remove HoverTrigger, add AnchorRef, make headings focusable - Update tests: remove hover test, add anchorRef test Co-authored-by: Navi <[email protected]>
- Use elevationVars['--elevation-menu'] instead of raw box-shadow string - Fix toggle bug: guard against light dismiss + click handler race condition - Default alignment to 'start' instead of 'center' (better mobile behavior) - CSS position-try-fallbacks already handles flipping when out of viewport Co-authored-by: Navi <[email protected]>
The :popover-open pseudo-class only matches the element with the [popover] attribute (rendered by useXDSLayer). The animation styles (opacity, transform, transitions) were on an inner child div, so :popover-open never matched and opacity stayed at 0. Split styles into: - popoverAnimation: opacity/transform/:popover-open → applied via xstyle to the actual popover element (matches useXDSHoverCard pattern) - container: background/radius/shadow → stays on inner content div Co-authored-by: Navi <[email protected]>
The popover was anchoring directly to the trigger element (e.g. XDSButton),
which receives :active { transform: scale(0.98) } on press. This caused
the CSS anchor position to shift when clicking to close, producing visible
jitter in the popover position.
Fix: Replace display:contents wrapper with an inline-flex wrapper that
acts as the CSS anchor. The wrapper generates a stable box for anchor
positioning while the trigger element inside it can transform freely
without affecting the anchor position.
Co-authored-by: Navi <[email protected]>
…ventListener Keyboard interactions (Enter/Space) weren't working because the popover was imperatively attaching click handlers to child DOM elements. This approach bypasses React's event system and can interfere with keyboard event synthesis. Fix: Move click handling to a React onClick on the anchor wrapper. Click events from children (e.g. XDSButton) naturally bubble up to the wrapper, including keyboard-synthesized clicks from native buttons. The wrapper now serves two purposes: 1. Stable CSS anchor (inline-flex, no pressed transforms) 2. Click target via React event bubbling Children are purely about defining the anchor content — no imperative event listener attachment needed. ARIA attributes still go on the child element for correct screen reader announcements. Co-authored-by: Navi <[email protected]>
The popover implements the button + dialog ARIA pattern, so the trigger must be a <button> or [role="button"]. Previously, click handling was on the wrapper div (catching all bubbled clicks from any child) and ARIA attrs were set on firstElementChild regardless of its role. Changes: - Add findTriggerButton() helper that finds button/[role="button"] either as the element itself or as a descendant - Both children mode and sibling mode use the same attachTrigger() function to apply click/keydown handlers + ARIA attrs to the button - Add keydown handler for Enter/Space on role="button" elements (native <button> already synthesizes click, role="button" does not) - Remove onClick from wrapper div — it's now on the button directly - Dev warning when no button is found in children or anchorRef - New tests: nested button, role="button" ARIA, role="button" click, role="button" Enter/Space keyboard, missing button warning Co-authored-by: Navi <[email protected]>
The tsconfig does not include @types/node, so process is not a known global. The dev-only guards on console.warn calls caused TS2591 errors during the DTS generation step. Removed the environment check — these warnings only fire on actual misuse (missing button/role=button element), so they're safe to emit unconditionally.
0cf366f to
7d4acb2
Compare
* feat(core): add XDSPopover component Adds XDSPopover — a general-purpose popover built on useXDSLayer. Features: - Anchored positioning with 12 placement options - Click-outside and Escape to dismiss - Focus management (auto-focus first focusable or heading) - Entry animation (fade + slide) - Default padding matching HoverCard - Accessible: role=dialog, aria-labelledby, focus trap Co-authored-by: Navi <[email protected]> * fix(storybook): use real XDS components in Popover stories Replace placeholder divs with realistic content using XDSHeading, XDSText, XDSSwitch, XDSCheckboxInput, XDSDivider, etc. Stories now demonstrate real use cases: - Settings panel with toggles - Filter panel with checkboxes and apply/reset - Confirmation dialog with destructive action - Hover profile card - Keyboard shortcuts reference (above placement) * refactor(core): address popover review feedback - Remove hover trigger — use XDSHoverCard for hover overlays - Remove hasFocusTrap prop — always enforce focus trapping - Remove initialIsShown prop — simplify to controlled/uncontrolled - Inline ClickPopover — no separate component needed - Add anchorRef support — sibling-mode rendering (matches XDSTooltip) - Simplify click handler — delegate to hook's toggle() - Add explicit color to container — ensure text visibility in top layer - Remove XDSPopoverTrigger type export - Update stories: remove HoverTrigger, add AnchorRef, make headings focusable - Update tests: remove hover test, add anchorRef test Co-authored-by: Navi <[email protected]> * fix(core): address round 2 popover review feedback - Use elevationVars['--elevation-menu'] instead of raw box-shadow string - Fix toggle bug: guard against light dismiss + click handler race condition - Default alignment to 'start' instead of 'center' (better mobile behavior) - CSS position-try-fallbacks already handles flipping when out of viewport Co-authored-by: Navi <[email protected]> * fix(core): move popover animation styles to popover element The :popover-open pseudo-class only matches the element with the [popover] attribute (rendered by useXDSLayer). The animation styles (opacity, transform, transitions) were on an inner child div, so :popover-open never matched and opacity stayed at 0. Split styles into: - popoverAnimation: opacity/transform/:popover-open → applied via xstyle to the actual popover element (matches useXDSHoverCard pattern) - container: background/radius/shadow → stays on inner content div Co-authored-by: Navi <[email protected]> * fix(popover): use stable anchor wrapper to prevent position jitter The popover was anchoring directly to the trigger element (e.g. XDSButton), which receives :active { transform: scale(0.98) } on press. This caused the CSS anchor position to shift when clicking to close, producing visible jitter in the popover position. Fix: Replace display:contents wrapper with an inline-flex wrapper that acts as the CSS anchor. The wrapper generates a stable box for anchor positioning while the trigger element inside it can transform freely without affecting the anchor position. Co-authored-by: Navi <[email protected]> * fix(popover): use React onClick on wrapper instead of imperative addEventListener Keyboard interactions (Enter/Space) weren't working because the popover was imperatively attaching click handlers to child DOM elements. This approach bypasses React's event system and can interfere with keyboard event synthesis. Fix: Move click handling to a React onClick on the anchor wrapper. Click events from children (e.g. XDSButton) naturally bubble up to the wrapper, including keyboard-synthesized clicks from native buttons. The wrapper now serves two purposes: 1. Stable CSS anchor (inline-flex, no pressed transforms) 2. Click target via React event bubbling Children are purely about defining the anchor content — no imperative event listener attachment needed. ARIA attributes still go on the child element for correct screen reader announcements. Co-authored-by: Navi <[email protected]> * fix(popover): target button/role=button for event handlers and ARIA The popover implements the button + dialog ARIA pattern, so the trigger must be a <button> or [role="button"]. Previously, click handling was on the wrapper div (catching all bubbled clicks from any child) and ARIA attrs were set on firstElementChild regardless of its role. Changes: - Add findTriggerButton() helper that finds button/[role="button"] either as the element itself or as a descendant - Both children mode and sibling mode use the same attachTrigger() function to apply click/keydown handlers + ARIA attrs to the button - Add keydown handler for Enter/Space on role="button" elements (native <button> already synthesizes click, role="button" does not) - Remove onClick from wrapper div — it's now on the button directly - Dev warning when no button is found in children or anchorRef - New tests: nested button, role="button" ARIA, role="button" click, role="button" Enter/Space keyboard, missing button warning Co-authored-by: Navi <[email protected]> * fix(popover): remove process.env.NODE_ENV guard that breaks DTS build The tsconfig does not include @types/node, so process is not a known global. The dev-only guards on console.warn calls caused TS2591 errors during the DTS generation step. Removed the environment check — these warnings only fire on actual misuse (missing button/role=button element), so they're safe to emit unconditionally. --------- Co-authored-by: Navi <[email protected]> Co-authored-by: Navi <[email protected]>
* feat(core): add XDSPopover component Adds XDSPopover — a general-purpose popover built on useXDSLayer. Features: - Anchored positioning with 12 placement options - Click-outside and Escape to dismiss - Focus management (auto-focus first focusable or heading) - Entry animation (fade + slide) - Default padding matching HoverCard - Accessible: role=dialog, aria-labelledby, focus trap Co-authored-by: Navi <[email protected]> * fix(storybook): use real XDS components in Popover stories Replace placeholder divs with realistic content using XDSHeading, XDSText, XDSSwitch, XDSCheckboxInput, XDSDivider, etc. Stories now demonstrate real use cases: - Settings panel with toggles - Filter panel with checkboxes and apply/reset - Confirmation dialog with destructive action - Hover profile card - Keyboard shortcuts reference (above placement) * refactor(core): address popover review feedback - Remove hover trigger — use XDSHoverCard for hover overlays - Remove hasFocusTrap prop — always enforce focus trapping - Remove initialIsShown prop — simplify to controlled/uncontrolled - Inline ClickPopover — no separate component needed - Add anchorRef support — sibling-mode rendering (matches XDSTooltip) - Simplify click handler — delegate to hook's toggle() - Add explicit color to container — ensure text visibility in top layer - Remove XDSPopoverTrigger type export - Update stories: remove HoverTrigger, add AnchorRef, make headings focusable - Update tests: remove hover test, add anchorRef test Co-authored-by: Navi <[email protected]> * fix(core): address round 2 popover review feedback - Use elevationVars['--elevation-menu'] instead of raw box-shadow string - Fix toggle bug: guard against light dismiss + click handler race condition - Default alignment to 'start' instead of 'center' (better mobile behavior) - CSS position-try-fallbacks already handles flipping when out of viewport Co-authored-by: Navi <[email protected]> * fix(core): move popover animation styles to popover element The :popover-open pseudo-class only matches the element with the [popover] attribute (rendered by useXDSLayer). The animation styles (opacity, transform, transitions) were on an inner child div, so :popover-open never matched and opacity stayed at 0. Split styles into: - popoverAnimation: opacity/transform/:popover-open → applied via xstyle to the actual popover element (matches useXDSHoverCard pattern) - container: background/radius/shadow → stays on inner content div Co-authored-by: Navi <[email protected]> * fix(popover): use stable anchor wrapper to prevent position jitter The popover was anchoring directly to the trigger element (e.g. XDSButton), which receives :active { transform: scale(0.98) } on press. This caused the CSS anchor position to shift when clicking to close, producing visible jitter in the popover position. Fix: Replace display:contents wrapper with an inline-flex wrapper that acts as the CSS anchor. The wrapper generates a stable box for anchor positioning while the trigger element inside it can transform freely without affecting the anchor position. Co-authored-by: Navi <[email protected]> * fix(popover): use React onClick on wrapper instead of imperative addEventListener Keyboard interactions (Enter/Space) weren't working because the popover was imperatively attaching click handlers to child DOM elements. This approach bypasses React's event system and can interfere with keyboard event synthesis. Fix: Move click handling to a React onClick on the anchor wrapper. Click events from children (e.g. XDSButton) naturally bubble up to the wrapper, including keyboard-synthesized clicks from native buttons. The wrapper now serves two purposes: 1. Stable CSS anchor (inline-flex, no pressed transforms) 2. Click target via React event bubbling Children are purely about defining the anchor content — no imperative event listener attachment needed. ARIA attributes still go on the child element for correct screen reader announcements. Co-authored-by: Navi <[email protected]> * fix(popover): target button/role=button for event handlers and ARIA The popover implements the button + dialog ARIA pattern, so the trigger must be a <button> or [role="button"]. Previously, click handling was on the wrapper div (catching all bubbled clicks from any child) and ARIA attrs were set on firstElementChild regardless of its role. Changes: - Add findTriggerButton() helper that finds button/[role="button"] either as the element itself or as a descendant - Both children mode and sibling mode use the same attachTrigger() function to apply click/keydown handlers + ARIA attrs to the button - Add keydown handler for Enter/Space on role="button" elements (native <button> already synthesizes click, role="button" does not) - Remove onClick from wrapper div — it's now on the button directly - Dev warning when no button is found in children or anchorRef - New tests: nested button, role="button" ARIA, role="button" click, role="button" Enter/Space keyboard, missing button warning Co-authored-by: Navi <[email protected]> * fix(popover): remove process.env.NODE_ENV guard that breaks DTS build The tsconfig does not include @types/node, so process is not a known global. The dev-only guards on console.warn calls caused TS2591 errors during the DTS generation step. Removed the environment check — these warnings only fire on actual misuse (missing button/role=button element), so they're safe to emit unconditionally. --------- Co-authored-by: Navi <[email protected]> Co-authored-by: Navi <[email protected]>
* feat(core): add XDSPopover component
Adds XDSPopover — a general-purpose popover built on useXDSLayer.
Features:
- Anchored positioning with 12 placement options
- Click-outside and Escape to dismiss
- Focus management (auto-focus first focusable or heading)
- Entry animation (fade + slide)
- Default padding matching HoverCard
- Accessible: role=dialog, aria-labelledby, focus trap
* fix(storybook): use real XDS components in Popover stories
Replace placeholder divs with realistic content using XDSHeading,
XDSText, XDSSwitch, XDSCheckboxInput, XDSDivider, etc.
Stories now demonstrate real use cases:
- Settings panel with toggles
- Filter panel with checkboxes and apply/reset
- Confirmation dialog with destructive action
- Hover profile card
- Keyboard shortcuts reference (above placement)
* refactor(core): address popover review feedback
- Remove hover trigger — use XDSHoverCard for hover overlays
- Remove hasFocusTrap prop — always enforce focus trapping
- Remove initialIsShown prop — simplify to controlled/uncontrolled
- Inline ClickPopover — no separate component needed
- Add anchorRef support — sibling-mode rendering (matches XDSTooltip)
- Simplify click handler — delegate to hook's toggle()
- Add explicit color to container — ensure text visibility in top layer
- Remove XDSPopoverTrigger type export
- Update stories: remove HoverTrigger, add AnchorRef, make headings focusable
- Update tests: remove hover test, add anchorRef test
* fix(core): address round 2 popover review feedback
- Use elevationVars['--elevation-menu'] instead of raw box-shadow string
- Fix toggle bug: guard against light dismiss + click handler race condition
- Default alignment to 'start' instead of 'center' (better mobile behavior)
- CSS position-try-fallbacks already handles flipping when out of viewport
* fix(core): move popover animation styles to popover element
The :popover-open pseudo-class only matches the element with the
[popover] attribute (rendered by useXDSLayer). The animation styles
(opacity, transform, transitions) were on an inner child div, so
:popover-open never matched and opacity stayed at 0.
Split styles into:
- popoverAnimation: opacity/transform/:popover-open → applied via xstyle
to the actual popover element (matches useXDSHoverCard pattern)
- container: background/radius/shadow → stays on inner content div
* fix(popover): use stable anchor wrapper to prevent position jitter
The popover was anchoring directly to the trigger element (e.g. XDSButton),
which receives :active { transform: scale(0.98) } on press. This caused
the CSS anchor position to shift when clicking to close, producing visible
jitter in the popover position.
Fix: Replace display:contents wrapper with an inline-flex wrapper that
acts as the CSS anchor. The wrapper generates a stable box for anchor
positioning while the trigger element inside it can transform freely
without affecting the anchor position.
* fix(popover): use React onClick on wrapper instead of imperative addEventListener
Keyboard interactions (Enter/Space) weren't working because the popover
was imperatively attaching click handlers to child DOM elements. This
approach bypasses React's event system and can interfere with keyboard
event synthesis.
Fix: Move click handling to a React onClick on the anchor wrapper.
Click events from children (e.g. XDSButton) naturally bubble up to the
wrapper, including keyboard-synthesized clicks from native buttons.
The wrapper now serves two purposes:
1. Stable CSS anchor (inline-flex, no pressed transforms)
2. Click target via React event bubbling
Children are purely about defining the anchor content — no imperative
event listener attachment needed. ARIA attributes still go on the child
element for correct screen reader announcements.
* fix(popover): target button/role=button for event handlers and ARIA
The popover implements the button + dialog ARIA pattern, so the trigger
must be a <button> or [role="button"]. Previously, click handling was
on the wrapper div (catching all bubbled clicks from any child) and
ARIA attrs were set on firstElementChild regardless of its role.
Changes:
- Add findTriggerButton() helper that finds button/[role="button"]
either as the element itself or as a descendant
- Both children mode and sibling mode use the same attachTrigger()
function to apply click/keydown handlers + ARIA attrs to the button
- Add keydown handler for Enter/Space on role="button" elements
(native <button> already synthesizes click, role="button" does not)
- Remove onClick from wrapper div — it's now on the button directly
- Dev warning when no button is found in children or anchorRef
- New tests: nested button, role="button" ARIA, role="button" click,
role="button" Enter/Space keyboard, missing button warning
* fix(popover): remove process.env.NODE_ENV guard that breaks DTS build
The tsconfig does not include @types/node, so process is not a known
global. The dev-only guards on console.warn calls caused TS2591 errors
during the DTS generation step.
Removed the environment check — these warnings only fire on actual
misuse (missing button/role=button element), so they're safe to emit
unconditionally.
---------

Extracts XDSPopover from #286 so it can land independently. Typeahead and Tokenizer will follow in a separate PR.
What's included
XDSPopovercomponent built onuseXDSLayerrole=dialog,aria-labelledby, focus trapWhat's NOT included (stays in #286)
XDSTypeahead— will be a follow-up PRXDSTokenizer— will be a follow-up PRCloses #175
Crafted with care by Navi