Commit 7a6fb7c
authored
[Scrollable] refactor: rewrite Scrollable utilizing platform features (#7443)
<!--
☝️How to write a good PR title:
- Prefix it with [ComponentName] (if applicable), for example: [Button]
- Start with a verb, for example: Add, Delete, Improve, Fix…
- Give as much context as necessary and as little as possible
- Prefix it with [WIP] while it’s a work in progress
-->
### WHY are these changes introduced?
This updates the Scrollable component to be a function component, but
also changes the fundamental implementation strategy.
It no longer controls the DOM node's scroll, allowing the platform to
handle all scrolling interaction and only using native features to
supply enhancements for the `ScrollTo` component and the scroll `hint`
functionality.
Primary Benefits:
- It allows for smooth scrolling in React 18 on iOS. Since we are no
longer setting scroll position on the target element as a side effect of
state, it has no conflict with automatic batching by React. See
#7424
- There are minimal wasted renders when scrolling. Previously, we would
render many times just by virtue of scrolling.
resolves #7424
### WHAT is this pull request doing?
<details>
<summary>Before/After 👀</summary>
#### Before

Momentum scrolling interrupted by render/commit cycles
https://user-images.githubusercontent.com/8847861/196776562-0517c364-9992-4415-973d-6d77843a4f0b.mov
#### After

Smooth scrolling
https://user-images.githubusercontent.com/8847861/196776608-5464f140-ee9b-437b-9229-6a80f4cb7a87.mov
</details>
### How to 🎩
🖥 [Local development
instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development)
🗒 [General tophatting
guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md)
📄 [Changelog
guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog)
Access storybook on an iOS device:

Using iOS device, navigate to the `Scrollable` component:
`http://<your.network.ip>:6006/?path=/story/all-components-scrollable--default&globals=profiler:true`
- [ ] On `main` branch: scrolling should be janky - experience is
choppy, momentum gets interrupted
- [ ] On this branch: scrolling should be smooth
- [ ] `shadow` prop works as intended
- [ ] `hint` prop works as intended
- [ ] `ScrollTo` component works within `Scrollable`
### 🎩 checklist
- [ ] Tested on
[mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing)
- [ ] Tested on [multiple
browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
- [ ] Tested for
[accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md)
- [ ] Updated the component's `README.md` with documentation changes
- [ ] [Tophatted
documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md)
changes in the style guide1 parent db951f8 commit 7a6fb7c
File tree
4 files changed
+266
-213
lines changed- .changeset
- polaris-react/src/components/Scrollable
4 files changed
+266
-213
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 30 | | |
35 | 31 | | |
36 | 32 | | |
| |||
Lines changed: 148 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
13 | 43 | | |
14 | 44 | | |
15 | 45 | | |
| |||
124 | 154 | | |
125 | 155 | | |
126 | 156 | | |
127 | | - | |
| 157 | + | |
128 | 158 | | |
129 | 159 | | |
130 | | - | |
| 160 | + | |
131 | 161 | | |
132 | 162 | | |
133 | 163 | | |
| |||
176 | 206 | | |
177 | 207 | | |
178 | 208 | | |
179 | | - | |
180 | | - | |
181 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
182 | 212 | | |
183 | 213 | | |
184 | 214 | | |
| |||
416 | 446 | | |
417 | 447 | | |
418 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
0 commit comments