feat(popover): migrate to native CSS anchor positioning and add scroll straregies - #2355
feat(popover): migrate to native CSS anchor positioning and add scroll straregies#2355rkaraivanov wants to merge 2 commits into
Conversation
…l strategies
Position igc-popover through native CSS anchor positioning in browsers
that support it (Chrome/Edge 133+, Firefox 147+, Safari 26+). Other
browsers keep the @floating-ui/dom behavior, and that module now loads
on demand only there.
Popovers hide while their anchor is scrolled fully out of view. The new
scroll-strategy attribute ('scroll' | 'hide' | 'close', default 'hide')
controls this on igc-popover, dropdown, select, combo, color picker,
date picker, date range picker and tooltip. With 'close' the popover
emits the non-bubbling igcPopoverScrollClose event so the host that
owns the open state can dismiss it. Each affected component gets an
InScrollingPanel story showcasing the strategies.
BREAKING CHANGE: The shift, shift-padding and inline properties of
igc-popover are removed - use flip to keep a popover in view.
PopoverScrollStrategy drops 'block' and its default changes from
'scroll' to 'hide'; 'block' or any unknown value behaves as 'hide'.
There was a problem hiding this comment.
🟡 Changes recommended
The updated popover test suite uses async describe callbacks (Mocha does not await suite definitions), which should be fixed to avoid unreliable or confusing test behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR migrates igc-popover positioning to use native CSS anchor positioning when available, with an on-demand @floating-ui/dom fallback, and introduces a unified scroll-strategy API (scroll | hide | close) across multiple popover-based components and their Storybook stories/tests.
Changes:
- Added a native anchor-positioning strategy for
igc-popoverwith a floating-ui fallback that lazy-loads only when needed. - Introduced/updated
scroll-strategysupport (defaulting tohide) across popover consumers (select, dropdown, combo, date pickers, color picker, tooltip) and added “InScrollingPanel” stories. - Updated/expanded unit tests to cover strategy selection, anchor visibility behavior, and the new scroll close signaling/event flow.
File summaries
| File | Description |
|---|---|
| stories/tooltip.stories.ts | Adds scrollStrategy control and an InScrollingPanel story demonstrating strategies. |
| stories/select.stories.ts | Updates scrollStrategy options/default and adds InScrollingPanel story. |
| stories/dropdown.stories.ts | Updates scrollStrategy options/default and revises story description to match new behavior. |
| stories/date-range-picker.stories.ts | Adds scrollStrategy control/default and InScrollingPanel story; notes dialog-mode behavior. |
| stories/date-picker.stories.ts | Adds scrollStrategy control/default and InScrollingPanel story; notes dialog-mode behavior. |
| stories/combo.stories.ts | Adds scrollStrategy control/default and InScrollingPanel story. |
| stories/color-picker.stories.ts | Adds scrollStrategy control/default and InScrollingPanel story. |
| src/internals/controllers/root-scroll.ts | Removes the old root scroll controller (superseded by popover behavior). |
| src/components/types.ts | Updates PopoverScrollStrategy type to `'scroll' |
| src/components/tooltip/tooltip.ts | Adds scrollStrategy to tooltip and wires popover close-on-scroll event handling. |
| src/components/tooltip/tooltip.spec.ts | Adds scroll-strategy tests for tooltip behavior, including sticky close behavior. |
| src/components/select/select.ts | Removes root scroll controller usage; forwards scrollStrategy to popover and closes on scroll-close event. |
| src/components/select/select.spec.ts | Updates scroll-strategy tests (removes old block coverage). |
| src/components/popover/themes/light/popover.base.scss | Adds native anchor-positioning CSS rules keyed off data-anchored/placement/strategy attributes. |
| src/components/popover/position/types.ts | Introduces shared positioning types and feature detection + test forcing hooks. |
| src/components/popover/position/native.ts | Implements the native CSS anchor positioning strategy (including arrow updates). |
| src/components/popover/position/floating.ts | Implements floating-ui strategy with dynamic import and scroll-strategy hiding middleware. |
| src/components/popover/position/arrow.ts | Extracts shared arrow styling logic used by both strategies. |
| src/components/popover/popover.ts | Refactors popover to strategy-based positioning, adds scrollStrategy, emits igcPopoverScrollClose on scroll when configured. |
| src/components/popover/popover.spec.ts | Adds native/fallback strategy suites and new behavioral tests (placement matrix, visibility, scroll-close). |
| src/components/dropdown/dropdown.ts | Removes root scroll controller usage; forwards scrollStrategy to popover and closes on scroll-close event. |
| src/components/dropdown/dropdown.spec.ts | Updates scroll-strategy tests (removes old block coverage). |
| src/components/date-range-picker/date-range-picker-single.spec.ts | Adds end-to-end smoke test for close scroll strategy on date range picker. |
| src/components/date-range-picker/date-range-mask-parser.spec.ts | Stabilizes month spin assertions by mirroring the clamp behavior. |
| src/components/date-picker/date-picker.spec.ts | Adds scroll-strategy tests, including dialog-mode ignore behavior. |
| src/components/date-picker/date-picker.base.ts | Adds scrollStrategy to picker base and forwards it to popover + closes on scroll-close event. |
| src/components/combo/combo.ts | Adds scrollStrategy to combo and forwards it to popover + closes on scroll-close event. |
| src/components/combo/combo.spec.ts | Adds scroll-strategy tests for combo. |
| src/components/color-picker/color-picker.ts | Adds scrollStrategy to color picker and forwards it to popover + closes on scroll-close event. |
| src/components/color-picker/color-picker.spec.ts | Adds scroll-strategy tests for color picker. |
| CHANGELOG.md | Documents the new scroll-strategy attribute and popover positioning change (including breaking changes). |
Review details
Suppressed comments (1)
src/components/popover/popover.spec.ts:195
- The enclosing suite is defined as
describe('Non-slotted anchor element', async () => …)(line 189). Mocha suite definitions should be synchronous;describe(async () => …)is not awaited by Mocha. Removeasyncfrom thatdescribecallback.
const root = await fixture<HTMLElement>(createNonSlottedPopover(true));
- Files reviewed: 31/31 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| }); | ||
|
|
||
| function definePositioningSuites(mode: PositionMode) { | ||
| describe('Slotted anchor element', async () => { |
Description
Position igc-popover through native CSS anchor positioning in browsers that support it (Chrome/Edge 133+, Firefox 147+, Safari 26+). Other browsers keep the @floating-ui/dom behavior, and that module now loads on demand only there.
Popovers hide while their anchor is scrolled fully out of view. The new scroll-strategy attribute ('scroll' | 'hide' | 'close', default 'hide') controls this on igc-popover, dropdown, select, combo, color picker, date picker, date range picker and tooltip. With 'close' the popover emits the non-bubbling igcPopoverScrollClose event so the host that owns the open state can dismiss it. Each affected component gets an InScrollingPanel story showcasing the strategies.
BREAKING CHANGE: The shift, shift-padding and inline properties of igc-popover are removed - use flip to keep a popover in view. PopoverScrollStrategy drops 'block' and its default changes from 'scroll' to 'hide'; 'block' or any unknown value behaves as 'hide'.
Type of Change
Checklist