[material-ui][Tabs] Respect scroll-padding when scrolling the selected tab into view - #49039
Open
crispinc-omnea wants to merge 3 commits into
Open
[material-ui][Tabs] Respect scroll-padding when scrolling the selected tab into view#49039crispinc-omnea wants to merge 3 commits into
crispinc-omnea wants to merge 3 commits into
Conversation
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
Author
|
Could this also please be cherry-picked for v7? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Tabsscrolls the selected tab into view with its own arithmetic. It compares the tab'sgetBoundingClientRect()with the scroller's, and it stops when the two edges meet. It does not readscroll-paddingon the scroller.scroll-paddingis the CSS property for a scrollport that is partly covered by other content. NativescrollIntoView()respects it.Tabsdoes not.This matters when the scroll buttons are positioned over the strip instead of beside it. The selected tab then stops under the button, and the end of its label is hidden.
Reproduction: https://aonizparxqgithub-mhof--5173--017acfb7.local-credentialless.webcontainer.io/
Issue: #49038
Change
scrollSelectedIntoViewnow readsscroll-paddingon the scroller and keeps the tab inside it:scroll-padding-left(scroll-padding-topwhen vertical).scroll-padding-right(scroll-padding-bottomwhen vertical).<length>is used as is. A<percentage>is resolved against the scroller'sclientWidth(clientHeightwhen vertical).autoresolves to0.When no
scroll-paddingis set, both values are0and the arithmetic is the same as before. There is no API change.Tests
New cases in
Tabs.test.js:should account for scroll-padding-left when scrolling a tab into view on the leftshould account for scroll-padding-right when scrolling a tab into view on the rightshould resolve a percentage scroll-padding against the scroller clientWidthshould account for scroll-padding-bottom when scrolling a vertical tab into viewAll four assert the final
scrollLeft/scrollTop. They pass in the jsdom project and in the browser project (Chromium).Notes for reviewers
getComputedStylecall per selection change. Nothing runs per frame.left/rightthatscrollSelectedIntoViewalready uses.scroll-paddingset, the arithmetic is bit-identical to before.calc()value computes to a string thatparseFloatcannot read, so it resolves to0. This is the pre-fix behaviour, not a wrong scroll.v7.x; a cherry-pick would be welcome.