-
Notifications
You must be signed in to change notification settings - Fork 8
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
Scrollable tabs #2440
Merged
Merged
Scrollable tabs #2440
Conversation
This file contains 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
m-akinc
reviewed
Oct 16, 2024
packages/storybook/src/nimble/anchor-tabs/anchor-tabs-matrix.stories.ts
Outdated
Show resolved
Hide resolved
m-akinc
approved these changes
Oct 17, 2024
m-akinc
requested review from
rajsite,
jattasNI and
mollykreis
as code owners
October 17, 2024 21:40
jattasNI
reviewed
Oct 23, 2024
packages/nimble-components/src/anchor-tabs/testing/anchor-tabs.pageobject.ts
Outdated
Show resolved
Hide resolved
rajsite
reviewed
Oct 23, 2024
packages/storybook/src/nimble/anchor-tabs/anchor-tabs.stories.ts
Outdated
Show resolved
Hide resolved
rajsite
reviewed
Oct 23, 2024
packages/storybook/src/nimble/anchor-tabs/anchor-tabs.stories.ts
Outdated
Show resolved
Hide resolved
rajsite
reviewed
Oct 23, 2024
rajsite
reviewed
Oct 23, 2024
rajsite
reviewed
Oct 23, 2024
packages/storybook/src/nimble/anchor-tabs/anchor-tabs-matrix.stories.ts
Outdated
Show resolved
Hide resolved
rajsite
reviewed
Oct 23, 2024
rajsite
reviewed
Oct 23, 2024
rajsite
approved these changes
Oct 23, 2024
Co-authored-by: Milan Raj <[email protected]>
Co-authored-by: Milan Raj <[email protected]>
Co-authored-by: Milan Raj <[email protected]>
Co-authored-by: Milan Raj <[email protected]>
rajsite
reviewed
Oct 23, 2024
packages/nimble-components/src/anchor-tabs/tests/anchor-tabs.spec.ts
Outdated
Show resolved
Hide resolved
rajsite
reviewed
Oct 23, 2024
jattasNI
approved these changes
Oct 23, 2024
1 task
rajsite
pushed a commit
that referenced
this pull request
Oct 29, 2024
# Pull Request ## 🤨 Rationale The update to the `Tabs` component introducing scroll buttons #2440 also updated the `display` setting to `flex`. This resulted in a missed change in behavior with how the `TabPanel` might size to the height of the `Tabs` component. See [this discussion](https://dev.azure.com/ni/DevCentral/_git/Skyline/pullrequest/821815?discussionId=7029412). ## 👩💻 Implementation Just needed to set a style on `[part="tabpanel"]` to have `flex: 1;`. ## 🧪 Testing Added a Chromatic test that would fail without the style change. ## ✅ Checklist <!--- Review the list and put an x in the boxes that apply or ~~strike through~~ around items that don't (along with an explanation). --> - [ ] I have updated the project documentation to reflect my changes or determined no changes are needed.
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.
Pull Request
🤨 Rationale
👩💻 Implementation
Adding buttons to template which will show/hide based on width of the container for the tabs either exceeding visible area or not. Layout of tabs is now using
flex
instead ofgrid
(the original use ofgrid
wasn't clear to me).ResizeObserver
vsIntersectionObserver
I currently have opted to use a
ResizeObserver
for controlling when to show/hide the scroll buttons. The reason for this is two-fold:contentRect
for the element containing the tabs changes. This will occur if theTabs
component changes its width, when tabs or added or removed (if all tabs are visible), or when the content of a tab is changed (when all tabs are visible), all of which are valid conditions to re-evaluate whether we need to show or hide the scroll buttons.Two different approaches were used/attempted with the
IntersectionObserver
. The first involved observing eachTab
element. While this worked, the implementation was cumbersome and harder to reason about, as it involved extra state that theTabs
component had to maintain (a map that tracked which tabs were currently visible or not), and "calculating" the visible condition from the state kept in the map. This was required to handle cases such as removing the last tab, where it was only partially visible (and thus was currently showing the scroll buttons), which, when removed, theIntersectionObserver
would only report a change for the removed tab, but the visibility should still be updated.The other approach attempted was trying to simply observe the container element of the tabs (whose
root
was simply its containing element), which wouldn't have required any extra state. However, this requires the observer to fire both when the container element becomes partially visible and when it becomes fully visible. Supplying thresholds of [0, 1] (one pixel and 100% visible), or only 0, did not result in the needed behavior. It would simply fire once, and then never again.🧪 Testing
Added unit tests, and matrix tests.
✅ Checklist