Skip to content

Conversation

@sophschneider
Copy link
Contributor

@sophschneider sophschneider commented Jan 4, 2024

WHY are these changes introduced?

Part of https://github.com/Shopify/polaris-internal/issues/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
Before-Scroll-Popover After-Scroll-Popover
before-taxes-overlay after-taxes-overlay

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 Scrollables

How to 🎩

  1. Go to Taxes settings
  2. Click "Sort" on the Manage sales tax collection card
  3. Scroll so the "Sort" button moves
  4. Make sure popover moves with button and closes when the button leaves the viewport

🎩 checklist

@sophschneider sophschneider force-pushed the sophie/popover-scroll-fix branch 3 times, most recently from 17d7ccb to dbecf98 Compare January 5, 2024 19:28
@Shopify Shopify deleted a comment from github-actions bot Jan 5, 2024
@Shopify Shopify deleted a comment from github-actions bot Jan 5, 2024
@sophschneider sophschneider force-pushed the sophie/popover-scroll-fix branch from dbecf98 to 719d218 Compare January 5, 2024 20:00
private setOverlay = (node: HTMLElement | null) => {
this.overlay = node;
};

Copy link
Contributor Author

@sophschneider sophschneider Jan 5, 2024

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.

Copy link
Contributor

@marty-Wallace marty-Wallace Jan 5, 2024

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?

Copy link
Contributor Author

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 :)

Copy link
Contributor Author

@sophschneider sophschneider Jan 8, 2024

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

Copy link
Contributor

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?

Copy link

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 👍

Copy link
Member

@chloerice chloerice Feb 13, 2024

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

Copy link
Contributor Author

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

Copy link
Member

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 🙏🏽

Copy link
Contributor Author

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

@sophschneider sophschneider force-pushed the sophie/popover-scroll-fix branch from 719d218 to d49229a Compare January 5, 2024 20:07
@sophschneider
Copy link
Contributor Author

/snapit

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2024

🫰✨ Thanks @sophschneider! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240105201004
yarn add @shopify/polaris@0.0.0-snapshot-release-20240105201004
yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240105201004
yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240105201004

@Shopify Shopify deleted a comment from github-actions bot Jan 5, 2024
@sophschneider sophschneider marked this pull request as ready for review January 5, 2024 20:29
@marty-Wallace
Copy link
Contributor

@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.

rake dev:products:create NUM=30 should do it.

@sophschneider
Copy link
Contributor Author

@marty-Wallace done!

@marty-Wallace
Copy link
Contributor

marty-Wallace commented Jan 5, 2024

cc: @mattkubej - this PR should fix popover scrolling in the bulk editor so the popovers track with their cells.

@sophschneider
Copy link
Contributor Author

/snapit

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2024

🫰✨ Thanks @sophschneider! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240105221218
yarn add @shopify/polaris@0.0.0-snapshot-release-20240105221218
yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240105221218
yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240105221218

@sophschneider sophschneider force-pushed the sophie/popover-scroll-fix branch from f8c1d12 to 81c90c4 Compare January 8, 2024 20:39
@sophschneider
Copy link
Contributor Author

/snapit

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2024

🫰✨ Thanks @sophschneider! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/polaris-migrator@0.0.0-snapshot-release-20240108204136
yarn add @shopify/polaris@0.0.0-snapshot-release-20240108204136
yarn add @shopify/polaris-tokens@0.0.0-snapshot-release-20240108204136
yarn add @shopify/stylelint-polaris@0.0.0-snapshot-release-20240108204136

@sophschneider sophschneider force-pushed the sophie/popover-scroll-fix branch from 81c90c4 to ff08934 Compare January 8, 2024 21:06
center.y < outer.top ||
center.y > outer.top + outer.height ||
inner.left < outer.left ||
inner.left + inner.width > outer.left + outer.width
Copy link
Contributor Author

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

@sophschneider sophschneider force-pushed the sophie/popover-scroll-fix branch from ff08934 to 31a2c16 Compare January 8, 2024 21:28
Copy link
Contributor

@marty-Wallace marty-Wallace left a 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?

Copy link
Member

@chloerice chloerice left a 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!! :shipit: 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)

@lgriffee lgriffee added the #gsd:38846 Admin Quality Improvements (Q1 2024) label Jan 25, 2024
@sophschneider sophschneider force-pushed the sophie/popover-scroll-fix branch from 31a2c16 to 749463d Compare February 21, 2024 15:49
@sophschneider
Copy link
Contributor Author

/snapit

@github-actions
Copy link
Contributor

Thanks @sophschneider! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/polaris-icons@0.0.0-snapshot-20240221155159
yarn add @shopify/polaris@0.0.0-snapshot-20240221155159

@sophschneider
Copy link
Contributor Author

/snapit

@github-actions
Copy link
Contributor

Thanks @sophschneider! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/polaris-icons@0.0.0-snapshot-20240221191730
yarn add @shopify/polaris@0.0.0-snapshot-20240221191730

@sophschneider sophschneider merged commit 0134d23 into main Feb 23, 2024
@sophschneider sophschneider deleted the sophie/popover-scroll-fix branch February 23, 2024 14:34
mrcthms pushed a commit that referenced this pull request Feb 26, 2024
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>
sophschneider added a commit that referenced this pull request Feb 27, 2024
…ers" (#11659)

Reverts #11399

Reverting because of some issues with the store switcher. Will remerge
when we fix the bugs
AnnaCheba pushed a commit to AnnaCheba/polaris that referenced this pull request Apr 22, 2024
…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|
|-|-|

|![Before-Scroll-Popover](https://github.com/Shopify/polaris/assets/20652326/f96652a0-bd20-4305-899e-6242ebb30496)|![After-Scroll-Popover](https://github.com/Shopify/polaris/assets/20652326/55cb30df-90e5-45b6-b337-819e9e05e376)|

|![before-taxes-overlay](https://github.com/Shopify/polaris/assets/20652326/c421bee0-0d64-4a06-a291-ee7e59d65382)|![after-taxes-overlay](https://github.com/Shopify/polaris/assets/20652326/d66cbfc5-7298-47f3-bd7a-a3b8e2d0a364)|

### 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:38846 Admin Quality Improvements (Q1 2024)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants