-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[PositionedOverlay] Add scroll support for all scroll containers #11399
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@shopify/polaris': minor | ||
| --- | ||
|
|
||
| Added `PositionedOverlay` scroll support for all scroll containers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,7 +117,12 @@ export function calculateHorizontalPosition( | |
| export function rectIsOutsideOfRect(inner: Rect, outer: Rect) { | ||
| const {center} = inner; | ||
|
|
||
| return center.y < outer.top || center.y > outer.top + outer.height; | ||
| return ( | ||
| center.y < outer.top || | ||
| center.y > outer.top + outer.height || | ||
| inner.left < outer.left || | ||
| inner.left + inner.width > outer.left + outer.width | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This closes the popover once it reaches the left or right side of the activator. This works with all alignments of the popover and I think looks nicer than closing when reaching the center of the activator |
||
| ); | ||
| } | ||
|
|
||
| export function intersectionWithViewport( | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Currently this is built to add vertically scrolling containers and not horizontally scrolling containers, but horizontal scroll support can be easily added if needed.
Performance is actually better than before since
Scrollable.forNodewas repeating a DOM search for iteration of the while loop. We are now doing single traversal while loop.Uh oh!
There was an error while loading. Please reload this page.
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.
Ah interesting. If there are enough rows in the bulk editor to cause the page to be vertically scrollable, then the popovers are also tracking with horizontal scrolling (I'm guessing since it is the same container that scrolls). But without a vertical scrollbar, the popovers do not track horizontally.
e.g.
Thoughts on adding horizontal containers as well?
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.
ill add them and see what it does! Wanted a good use case for it and the bulk editor is perfect :)
Uh oh!
There was an error while loading. Please reload this page.
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.
@marty-Wallace good news! I got it to work for horizontal scroll for both your examples above, but theres a problem with the bulk editor where the scroll container is registered as 100% full screen width behind the sticky column so it doesn't close the popover until the end of that scroll container. I can't really think of a way to fix this from polaris' end so we might have to modify the width of the bulk editor scroll container or make the sticky column z-index higher than the popover
horizontal-scroll.mov
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.
@sophschneider nice!
Any thoughts on this @lbenie or @mattkubej?
IMO - this is an improvement over the existing behaviour and we can fix the popover showing over the sticky column in the bulk editor as a follow up?
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.
Gotcha -- So 2 separate PRs but they both go out in the same polaris version? That's fine with me 👍
Uh oh!
There was an error while loading. Please reload this page.
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.
Since the popover staying visible when the activator is behind the sticky columns is already a bug in production and not introduced by these changes, we shouldn't block this PR from shipping now. @sophschneider
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.
@chloerice do we need it for your HoverCard PR? I was holding off on it in case there were conflicts and wanted you to merge in first
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.
I do need it, though it's not blocking. No worries about conflicts, should be minimal since we didn't make changes to the same part of the component 🙏🏽
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.
Hey all! As Chloe mentioned, this is less of a regression in the bulk editor and more of a side step to the existing experience.
When I mentioned
above, I explored both solutions and they aren't simple or fast to do as the bulk editor table is built by rows, not columns. So to elevate the sticky column above the popover, we would have semantically change the bulk editor table which is quite a big task.
I have some other solutions for the bulk editor team such as closing the popovers on scroll, but this would have to be implemented on a popover by popover basis in web.
If we don't get any major pushback, I'm going to go ahead an merge this to unblock other overlay work our team is doing