-
Notifications
You must be signed in to change notification settings - Fork 1k
Responsive Tabs #6137
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
Responsive Tabs #6137
Conversation
Some thoughts on the API surface ...
|
This is coming together really nicely. A couple of behavioral/stylistic comments.
Screen.Recording.2022-05-20.at.1.10.40.PM.mov |
src/js/components/Tabs/Tabs.js
Outdated
|
||
setDisableRightArrow(false); | ||
if (scrolledToIndex === 0) { | ||
// wait for scroll animation to finish |
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.
Do we need to let the animation finish? I think I expected it to become disabled more immediately
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.
If the button becomes disabled before the animation finishes, the animation will stop where it is and never continue. I'll try and mess around with this more though and see if there is a way around this because I agree, ideally the button could be disabled immediately and the animation would continue.
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 adjusted this code so that the button gets disabled as soon as the animation finishes instead of waiting half a second before being disabled. But I couldn't find a way around having to wait for the animation to finish.
disableRightArrow === undefined | ||
) { | ||
onResize(); | ||
} |
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.
When I refresh the page, the responsive controls aren't visible until I resize the page. Do we need to always call onResize
on the initial render (outside of this condition)?
Screen.Recording.2022-05-20.at.1.26.41.PM.mov
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.
Hmm I haven't been able to reproduce this behavior. Is it happening every time you are refreshing the page or is it only happening sometimes?
Yeah, I can see how naming this
I can't think of a case where the wrapping would be desirable. My only hesitation with making this the default behavior is that we have a storybook story Tabs/Responsive that is advertising that this is how we have been handling responsive tabs. So it feels like something that we have been considering a feature up to this point.
This makes sense. I will change |
In the current version, the previous and next buttons don't seem to be working for me. I can tab focus through. This is on Safari. |
I'm wondering if we should accommodate track pad interaction, since we are showing some tabs partially and mimicking scroll behavior. |
Hmm I just tested with Safari, Chrome, and Firefox. They arrow keys are working in all of them for me. The only difference is in Safari the 'smooth' scroll behavior isn't supported so the tab isn't sliding in or out like in the other browsers. I will push up changes soon based on the review comments and then if the arrow keys are still not working in Safari on your end I will investigate a little deeper why it is working differently on my end vs on your end. |
This was something Beza and I discussed. Her reasons for not wanting track pad scrolling were that a user could scroll quickly and miss a tab. I could revisit this topic with her though |
Fixed in latest commit |
Hmm... How is that different from any scroll situation, where the user can scroll quickly and skip over something? Perhaps the user knows they want the last tab and just want to get to it quickly, without having to step through each one to get there? I was noticing that when I had a small window size, it was a bit annoying to use the arrows to get back to the first tab after having clicked next through them all to review them. |
For me, Firefox and Safari still have this problem. On Edge, I don't see a problem with the right edge of Tab 12 but I do see it with the left edge of Tab 1 when going backwards. |
Edge and Firefox are working for me. Safari still isn't. |
I just chatted with Beza about this. She still feels that scrolling through the tabs is not a good experience. But she said we could allow the option to allow scrolling as a toggle in the theme and for the hpe theme set it so that we don't allow scrolling. |
An update on the Safari issue where the arrow keys don't scroll the select: There is an issue in v15.5 of safari where if a container has A pull request has been merged on the webkit repository to fix this (WebKit/WebKit#1387). This fix is not yet included in the latest version of Safari. The latest version of safari uses webkit Should we add a work around for this in the meantime? Or go ahead a move forward knowing it should be fixed on Safari's end soon? |
I wonder if our timing calculations are too precise for particular environments and not adaptive enough? I will pull the branch and experiment with them a bit. |
What does this PR do?
Changes the responsive behavior for Tabs. Previously tabs would wrap if there is not enough room. This PR changes the behavior so if there isn't enough room to show the tabs, only the tabs that fit will be displayed and left and right arrows will be displayed on either side of the Tabs header and can be used to view additional tabs. A number can be passed to the
step
prop to define the number of tabs the left and right arrows will move by. The default step is 1.Notes:
Where should the reviewer start?
What testing has been done on this PR?
Tested with Tabs/Responsive story
How should this be manually tested?
Do Jest tests follow these best practices?
screen
is used for querying.userEvent
is used in place offireEvent
.asFragment()
is used for snapshot testing.Any background context you want to provide?
What are the relevant issues?
Closes #6117
Screenshots (if appropriate)
Do the grommet docs need to be updated?
Yes, need to add
step
prop to docsShould this PR be mentioned in the release notes?
Yes
Is this change backwards compatible or is it a breaking change?
Backwards compatible