- 
                Notifications
    
You must be signed in to change notification settings  - Fork 56
 
Fix popover scroll parent detection in nested shadow DOM containers #1178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix popover scroll parent detection in nested shadow DOM containers #1178
Conversation
Co-authored-by: iOvergaard <752371+iOvergaard@users.noreply.github.com>
- Clear scroll parents array before repopulating to prevent duplicates - Add shadow DOM traversal support to old popover element - Enhanced both uui-popover and uui-popover-container components Co-authored-by: iOvergaard <752371+iOvergaard@users.noreply.github.com>
- Created test cases to verify scroll parent detection - Added visual demo to showcase the fix - Verified build and lint pass successfully Co-authored-by: iOvergaard <752371+iOvergaard@users.noreply.github.com>
Remove demo and extra test files, keeping only the essential fix and enhanced tests Co-authored-by: iOvergaard <752371+iOvergaard@users.noreply.github.com>
…c (recalculate every time)
| 
           Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1178.westeurope.azurestaticapps.net  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes scroll parent detection issues in popovers within nested shadow DOM containers. The main problem was that popovers couldn't properly identify their correct scroll parents across shadow DOM boundaries, causing incorrect positioning when intermediate scroll containers were scrolled.
- Prevents duplicate scroll parent accumulation when popovers are opened multiple times
 - Adds proper shadow DOM boundary traversal for scroll parent detection
 - Implements conditional logic for excluding static parents based on position state
 
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description | 
|---|---|
| packages/uui-popover/lib/uui-popover.element.ts | Adds scroll parent reset logic and shadow DOM traversal helper method | 
| packages/uui-popover-container/lib/uui-popover-container.element.ts | Fixes duplicate scroll parents and improves static parent exclusion logic | 
| packages/uui-popover-container/lib/uui-popover-container.test.ts | Adds comprehensive tests for nested shadow DOM scroll parent detection | 
| packages/uui-popover-container/lib/uui-popover-container.story.ts | Refactors story configuration and minor styling improvements | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| 
           Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1178.westeurope.azurestaticapps.net  | 
    
          
 | 
    
| 
           Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1178.westeurope.azurestaticapps.net  | 
    
          
 | 
    
| 
           Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-1178.westeurope.azurestaticapps.net  | 
    
| 
           @nielslyngsoe @iOvergaard i have testede it again also with the detail comment her #1006 (comment) and it still is not fixed :(  | 
    
| 
           @rammi987 the proposed fix is set to release in Umbraco 16.4. Can I ask how did you manage to test the new version on 16.3, did you build from source?  | 
    
| 
           @iOvergaard we Got told on the DR project by our umbraco contact it was a 16.3 fix.  | 
    
| 
           @rammi987 The first part of the fix was in 16.2, but the part that was not fixed the first time around is in UI library 1.16, which will land in CMS 16.4 and 17.0. Since the CMS includes the UI library, it is not possible to overwrite it in the browser even though your package has a reference to it. You will need to build the whole CMS from source to bump up the version of the UI library in the browser. The beta of 17.0, which also contains the supposed fix, will be available on NuGet next week. So, if have the chance to test it then, that would be very beneficial. We will then have the chance to fix up any further bugs before the final release.  | 
    
| 
           @iOvergaard thx for the detailed answer it make more sense. I’ll put our internal task about the bug to 16.4 and test it again at that time.  | 
    



Fixes the issue where popovers inside nested shadow DOM scroll containers could not properly detect their scroll parents, causing them to scroll incorrectly with grandparent frames instead of staying positioned relative to their triggers.
How to test
Check Storybook out on: https://delightful-beach-055ecb503-1178.westeurope.azurestaticapps.net/?path=/story/uui-popover-container--inside-shadow-dom-scroll-container
Problem
When a popover was placed inside another scrolling target within shadow DOM boundaries, it would fail to bind to the correct scroll parents. This resulted in popovers that would move incorrectly when intermediate scroll containers were scrolled, as reported in #1161.
The issue manifested in scenarios like:
When scrolling the inner container, the popover would not follow the button correctly.
Root Causes
Duplicate scroll parents: The
#getScrollParents()method inuui-popover-containerdidn't reset the scroll parents array before repopulating it, causing duplicate event listeners and incorrect behavior when the popover was opened multiple times.Shadow DOM boundary traversal: The older
uui-popovercomponent only usedparentElementfor DOM traversal, which doesn't cross shadow DOM boundaries, missing scroll containers in parent shadow roots.Solution
For
uui-popover-container:this.#scrollParents = [];at the beginning of#getScrollParents()to prevent accumulation of duplicate scroll parentsFor
uui-popover:_getAncestorElement()helper method that properly traverses shadow DOM boundaries by checking for shadow root hosts whenparentElementis null_getScrollParents()to use the new traversal methodCloses #1161