-
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
Conversation
17d7ccb to
dbecf98
Compare
dbecf98 to
719d218
Compare
| private setOverlay = (node: HTMLElement | null) => { | ||
| this.overlay = node; | ||
| }; | ||
|
|
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.forNode was repeating a DOM search for iteration of the while loop. We are now doing single traversal while loop.
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 :)
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 👍
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
might have to modify the width of the bulk editor scroll container or make the sticky column z-index higher than the popover
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
719d218 to
d49229a
Compare
|
/snapit |
|
🫰✨ Thanks @sophschneider! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240105201004yarn add @shopify/polaris@0.0.0-snapshot-release-20240105201004yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240105201004yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240105201004 |
|
@sophschneider could you add a few more products to your spin instance. I'd like to test out how this scrolling change affects some of the columns in the BulkEditor as well.
|
|
@marty-Wallace done! |
|
cc: @mattkubej - this PR should fix popover scrolling in the bulk editor so the popovers track with their cells. |
|
/snapit |
|
🫰✨ Thanks @sophschneider! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240105221218yarn add @shopify/polaris@0.0.0-snapshot-release-20240105221218yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240105221218yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240105221218 |
f8c1d12 to
81c90c4
Compare
|
/snapit |
|
🫰✨ Thanks @sophschneider! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240108204136yarn add @shopify/polaris@0.0.0-snapshot-release-20240108204136yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240108204136yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240108204136 |
81c90c4 to
ff08934
Compare
| center.y < outer.top || | ||
| center.y > outer.top + outer.height || | ||
| inner.left < outer.left || | ||
| inner.left + inner.width > outer.left + outer.width |
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.
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
ff08934 to
31a2c16
Compare
marty-Wallace
left a comment
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.
Nice work on this!
🎩'd and looks good to me, I'll leave it up to the core operate folks to determine how to make the bulk editor change in coordination with this?
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.
Awesome, thanks for fixing this @sophschneider!!
I can ping you or the bulk editor folks who have context on the z-index change needed to fix the sticky column issue in the upgrade PR (I've got one prepped for 12.11.0, but will be waiting to ship it until we get the backward compatibilty PR shipped for BulkActions/SelectAllActions)
31a2c16 to
749463d
Compare
|
/snapit |
|
✨ Thanks @sophschneider! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-icons@0.0.0-snapshot-20240221155159yarn add @shopify/polaris@0.0.0-snapshot-20240221155159 |
|
/snapit |
|
✨ Thanks @sophschneider! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/polaris-icons@0.0.0-snapshot-20240221191730yarn add @shopify/polaris@0.0.0-snapshot-20240221191730 |
This reverts commit 5aa75b1.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @shopify/polaris@12.19.0 ### Minor Changes - [#11399](#11399) [`0134d2378`](0134d23) Thanks [@sophschneider](https://github.com/sophschneider)! - Added `PositionedOverlay` scroll support for all scroll containers - [#11622](#11622) [`1f81501c8`](1f81501) Thanks [@mrcthms](https://github.com/mrcthms)! - Updated the BulkActions component to include logic to handling selecting and deselecting rows - [#11637](#11637) [`1ac638246`](1ac6382) Thanks [@mrcthms](https://github.com/mrcthms)! - Updated Pagination table variant to have more prominent and centrally-aligned actions ### Patch Changes - [#11644](#11644) [`b95fc9807`](b95fc98) Thanks [@kyledurand](https://github.com/kyledurand)! - Removed nav wrapper from breadcrumbs since it now only renders a single link ## polaris.shopify.com@0.63.2 ### Patch Changes - Updated dependencies \[[`0134d2378`](0134d23), [`1f81501c8`](1f81501), [`1ac638246`](1ac6382), [`b95fc9807`](b95fc98)]: - @shopify/polaris@12.19.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…pify#11399) ### WHY are these changes introduced? Part of Shopify/polaris-internal#1246 ### WHAT is this pull request doing? Before, the `PositionedOverlay` component (used by `Popover` and `Tooltip`) only scrolled with Polaris `Scrollable` components or the window. This PR adds support for all scroll containers so that `Popover` and `Tooltip` will always scroll with containers, even if its not wrapped in a `Scrollable`. |Before|After| |-|-| ||| ||| ### Alternative approaches I picked this approach since it decouples `PositionedOverlay` from `Scrollable` and doesn't require any extra setup or knowledge from consumers, it should "just work". If this approach is undesirable, we could also either: 1. Extend `Tooltip` and `Popover` to accept a `ref` to custom scrollable containers and keep automatic `Scrollable` detection 2. Export `data-polaris-scrollable` or another more generic attribute that consumers can add to their custom scroll elements. Then update `Tooltip` and `Popover` documentation to require proper scroll container setup 3. Extend the `Scrollable` component to support the scrolling features in the settings modal, refactor the settings modal to use `Scrollable`, and update `Tooltip` and `Popover` documentation to require that all scroll containers are `Scrollable`s ### How to 🎩 * https://5d559397bae39100201eedc1-fdxylxukuv.chromatic.com/?path=/story/all-components-popover--with-scroll-container * https://admin.web.web-ya2s.sophie-schneider.us.spin.dev/store/shop1/settings/taxes 1. Go to Taxes settings 4. Click "Sort" on the `Manage sales tax collection` card 5. Scroll so the "Sort" button moves 6. Make sure popover moves with button and closes when the button leaves the viewport ### 🎩 checklist - [x] Tested a [snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases) - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
WHY are these changes introduced?
Part of https://github.com/Shopify/polaris-internal/issues/1246
WHAT is this pull request doing?
Before, the
PositionedOverlaycomponent (used byPopoverandTooltip) only scrolled with PolarisScrollablecomponents or the window.This PR adds support for all scroll containers so that
PopoverandTooltipwill always scroll with containers, even if its not wrapped in aScrollable.Alternative approaches
I picked this approach since it decouples
PositionedOverlayfromScrollableand doesn't require any extra setup or knowledge from consumers, it should "just work". If this approach is undesirable, we could also either:TooltipandPopoverto accept arefto custom scrollable containers and keep automaticScrollabledetectiondata-polaris-scrollableor another more generic attribute that consumers can add to their custom scroll elements. Then updateTooltipandPopoverdocumentation to require proper scroll container setupScrollablecomponent to support the scrolling features in the settings modal, refactor the settings modal to useScrollable, and updateTooltipandPopoverdocumentation to require that all scroll containers areScrollablesHow to 🎩
https://5d559397bae39100201eedc1-fdxylxukuv.chromatic.com/?path=/story/all-components-popover--with-scroll-container
https://admin.web.web-ya2s.sophie-schneider.us.spin.dev/store/shop1/settings/taxes
Manage sales tax collectioncard🎩 checklist