-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Improve scrollbar experience in the admin #9701
Conversation
/snapit |
🫰✨ Thanks @martenbjork! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/[email protected] yarn add @shopify/[email protected] |
/snapit |
/snapit |
🫰✨ Thanks @martenbjork! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/[email protected] yarn add @shopify/[email protected] |
This does seem like it should prevent the jumping with the main content area. However, I think we might need to change the UX of the left navigation if we want to introduce a similar solution there. I suppose the jumping in the left navigation is less egregious in comparison to the main content. |
/snapit |
Looks like a changeset is absent from |
🫰✨ Thanks @martenbjork! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/[email protected] yarn add @shopify/[email protected] |
<div className={styles.SearchField}>{searchMarkup}</div> | ||
<div className={styles.SecondaryMenu}>{secondaryMenu}</div> | ||
{userMenu} | ||
<div className={styles.Container}> |
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 think this is going to conflict with what I just drafted here, where I'm converting the TopBar to a grid layout in order to achieve newly desired alignment of the elements. Specifically, the search field.
I'm guessing the Container is being added in this manner to constrain the width, but also allow the TopBar div to stretch the width of the screen. I suppose with the change I have above, the grid styles would then need to be applied to a child div of the Container div. What are your thoughts?
Something we'll need to be cognizant of with the ordering of delivering this and what I have staged.
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'm guessing the Container is being added in this manner to constrain the width, but also allow the TopBar div to stretch the width of the screen.
Correct!
the grid styles would then need to be applied to a child div of the Container div
Yeah, this sounds right to me. I'm basically just adding another child in here and adding display: flex
to it as well, so that the flex behaviour is passed down to the children below.
/snapit |
🫰✨ Thanks @martenbjork! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/[email protected] yarn add @shopify/[email protected] |
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.
👏
const parentEl = document.createElement('div'); | ||
parentEl.setAttribute( | ||
'style', | ||
`position: absolute; opacity: 0; transform: translate3d(-9999px, -9999px, 0); pointer-events: none; width:${SCROLLBAR_TEST_ELEMENT_PARENT_SIZE}px; height:${SCROLLBAR_TEST_ELEMENT_PARENT_SIZE}px;`, |
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.
Does this need to be 3d? Might be slightly more performant:
`position: absolute; opacity: 0; transform: translate3d(-9999px, -9999px, 0); pointer-events: none; width:${SCROLLBAR_TEST_ELEMENT_PARENT_SIZE}px; height:${SCROLLBAR_TEST_ELEMENT_PARENT_SIZE}px;`, | |
`position: absolute; opacity: 0; transform: translate(-9999px, -9999px); pointer-events: none; width:${SCROLLBAR_TEST_ELEMENT_PARENT_SIZE}px; height:${SCROLLBAR_TEST_ELEMENT_PARENT_SIZE}px;`, |
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 think translate3d
is more performant because it runs the process in the GPU but I haven't looked at this in awhile so it's worth double checking
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 is what I learned way back when too, but I wouldn't be surprised if the whole "trigger GPU" trick has passed its best before date 😀
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 was thinking it would be more performant because it shouldn't have to trigger the gpu. There's no visibility in this but yes, probably negligible
Give me a shout if you want help with rebasing with my latest changes to the |
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.
Clever. I like it! 👍
const parentEl = document.createElement('div'); | ||
parentEl.setAttribute( | ||
'style', | ||
`position: absolute; opacity: 0; transform: translate3d(-9999px, -9999px, 0); pointer-events: none; width:${SCROLLBAR_TEST_ELEMENT_PARENT_SIZE}px; height:${SCROLLBAR_TEST_ELEMENT_PARENT_SIZE}px;`, |
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 was thinking it would be more performant because it shouldn't have to trigger the gpu. There's no visibility in this but yes, probably negligible
/snapit |
🫰✨ Thanks @martenbjork! Your snapshots have been published to npm. Test the snapshots by updating your yarn add @shopify/[email protected] yarn add @shopify/[email protected] |
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.
Top hatted with and without editions enabled. LGTM!
Spoke with @martenbjork. I'll merge this through and shepherd this into |
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/[email protected] ### Minor Changes - [#9856](#9856) [`47652f7d6`](47652f7) Thanks [@heyjoethomas](https://github.com/heyjoethomas)! - Updates social media icons, removing them from their containers and adds a one for the Twitch platform. ## @shopify/[email protected] ### Minor Changes - [#10263](#10263) [`67699cb88`](67699cb) Thanks [@aveline](https://github.com/aveline)! - Added migration for `Button` component ## @shopify/[email protected] ### Minor Changes - [#9701](#9701) [`cbf539495`](cbf5394) Thanks [@martenbjork](https://github.com/martenbjork)! - Updated the Frame and Topbar components to stay clear of a scrollbar. This reduces the overall jumpiness in the UI when scrollbars appear and disappear when using a Polaris app. ### Patch Changes - [#10284](#10284) [`eba75d20a`](eba75d2) Thanks [@zakwarsame](https://github.com/zakwarsame)! - - Updated `Filters` query field to initialize with focus based on `mode` state - [#10282](#10282) [`9a2d4f62a`](9a2d4f6) Thanks [@kyledurand](https://github.com/kyledurand)! - Fixed pointer alignment on tooltip - [#10343](#10343) [`12a62b4d7`](12a62b4) Thanks [@mrcthms](https://github.com/mrcthms)! - Fixed UI inconsistencies in the mobile view of the IndexFilters - [#10276](#10276) [`abb50250e`](abb5025) Thanks [@highfieldjames](https://github.com/highfieldjames)! - Updated `TextField` of `type` `number` to focus when a `Spinner` button is clicked - Updated dependencies \[[`47652f7d6`](47652f7)]: - @shopify/[email protected] ## [email protected] ### Patch Changes - Updated dependencies \[[`47652f7d6`](47652f7), [`eba75d20a`](eba75d2), [`9a2d4f62a`](9a2d4f6), [`12a62b4d7`](12a62b4), [`cbf539495`](cbf5394), [`abb50250e`](abb5025)]: - @shopify/[email protected] - @shopify/[email protected] Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
## Context In MacOS's System Preferences > Appearance, choose these settings: <img width="475" alt="image" src="https://github.com/Shopify/polaris/assets/875708/2faa63e4-82ad-4fe1-8abe-7e0268c759f1"> Now browse the admin. As navigate between different pages, the body will sometimes overflow, sometimes not. This means scrollbars will come and go. For instance, while loading the data, the skeleton content will overflow and thus trigger scrollbars, but when minimal data comes in, the scrollbars might go away. This cases the UI to constantly jump ~15px left and right as the scrollbars come and go. ## This fix We thought _[a lot](https://docs.google.com/document/d/1AW7AFldJc6RZT4sHR303bqWMqLf0-CDXExEVf6hFg1w/edit#heading=h.e2bgx61b1bn2)_ about how we can improve the scrollbar behaviour. This PR completely circumvents the scrollbar logic by changing the layout constraints of Polaris core elements. It makes sure that, when a scrollbar is set to "always on", the content stays clear of the area where the scrollbar may appear. ### 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) <!-- Give as much information as needed to experiment with the component in the playground. --> <details> <summary>Copy-paste this code in <code>playground/Playground.tsx</code>:</summary> ```jsx import React from 'react'; import {Page} from '../src'; export function Playground() { return ( <Page title="Playground"> {/* Add the code you want to test in here */} </Page> ); } ``` </details> ### 🎩 checklist - [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) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide Tested on device types, browsers and operating systems. <img width="1143" alt="Screenshot 2023-07-20 at 4 30 42 PM" src="https://github.com/Shopify/polaris/assets/875708/40f29f11-60a1-4b03-a7e2-d5c37524e353"> <img width="1143" alt="Screenshot 2023-07-20 at 4 28 12 PM" src="https://github.com/Shopify/polaris/assets/875708/1f55d2ea-7963-46c3-bc72-719e9f26d1f6"> <img width="1208" alt="Screenshot 2023-07-20 at 4 32 38 PM" src="https://github.com/Shopify/polaris/assets/875708/3407960f-5be6-4192-b92c-cff56975a1b5">
Context
In MacOS's System Preferences > Appearance, choose these settings:
Now browse the admin. As navigate between different pages, the body will sometimes overflow, sometimes not. This means scrollbars will come and go. For instance, while loading the data, the skeleton content will overflow and thus trigger scrollbars, but when minimal data comes in, the scrollbars might go away.
This cases the UI to constantly jump ~15px left and right as the scrollbars come and go.
This fix
We thought a lot about how we can improve the scrollbar behaviour.
This PR completely circumvents the scrollbar logic by changing the layout constraints of Polaris core elements.
It makes sure that, when a scrollbar is set to "always on", the content stays clear of the area where the scrollbar may appear.
How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist
README.md
with documentation changesTested on device types, browsers and operating systems.