Skip to content
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

feat(vertical-tabs): new tab variant #16701

Conversation

ariellalgilmore
Copy link
Member

@ariellalgilmore ariellalgilmore commented Jun 5, 2024

#16305

Adds a new vertical variant to tabs
Screenshot 2024-06-05 at 10 54 44 AM

Changelog

New

  • TabListVertical component
  • TabPanels new update to check if vertical variant and set the same max height to each TabPanel
  • Tab new update to add ellipsis with Tooltip only on vertical variant

Changed

  • added overflow-x: hidden to default Tabs ... fixed an issue where an unwanted horizontal scroll would appear if the length of the tabs is too long

Other notes:

  • using float: inline-start to align the vertical tabs. This avoid wrapping the component in <Grid>, which causes complexities when going between sm and other breakpoints, but I know float isn't really used any more
  • for TabPanels, I have to unhide/hide each Panel to get the current height and then use style.height = ... for each TabPanel to set what the height of the largest height for each. I am not noticing any flashing, but could be a concern
  • keeping as a draft since waiting for confirmed overflow styles and if the sm breakpoint should be default tabs or contained tabs
  • still need to update docs too

Testing / Reviewing

{{ Add descriptions, steps or a checklist for how reviewers can verify this PR works or not }}

Copy link

netlify bot commented Jun 5, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 66c7133
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/66675314aa7e0800085b2d09
😎 Deploy Preview https://deploy-preview-16701--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jun 5, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 66c7133
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/66675314e6e0350008bd3ea1
😎 Deploy Preview https://deploy-preview-16701--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@alisonjoseph
Copy link
Member

This is looking good! My one question, which may be more for design, is around the 25% width. I think this might work as a default, but I can see scenarios where someone might need to align/wrap this on the grid. Perhaps it needs a width prop where you can set a width, or leave it as 100% so the user can place it within their own container?

We solved a somewhat similar problem for grid-aligned contained tabs with a combination of grid components and a fullwidth prop. https://react.carbondesignsystem.com/?path=/docs/components-tabs--overview#tabs-and-the-grid---fullwidth-prop

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some scrollIntoView related observations/questions:

It's possible to select a tab and not be able to see it. The focus ring is obscured by the gradient which might be an accessibility failure?
CleanShot.2024-06-07.at.10.43.33.mp4
When a tab is selected and the browser size changes the tab isn't visible in some cases - both in the vertical config and the smaller horizontal config
CleanShot.2024-06-07.at.10.47.01.mp4

Comment on lines +1566 to +1571
// un-hide hidden Tab Panels to get heights
refs.current.forEach((ref) => {
if (ref) {
ref.hidden = false;
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the intent here, I think you could avoid having to unhide them like this by using useLayoutEffect. It's specifically geared towards logic that needs to measure the dom.

OR maybe this justifies having a wrapper component around the tabs and the tabpanels. That way we wouldn't have to measure anything and it could be done with CSS. Honestly I'd be up for that approach over measuring with js to match heights. Are there any downsides of a wrapper element that you can think of?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the useLayoutEffect would work here as well!

When trying this:

useLayoutEffect(() => {
      refs.current.forEach((ref) => {
        console.log(ref?.offsetHeight);
      });
});
Screenshot 2024-06-07 at 9 53 47 AM ^ i would only get the following printed... the only visible height 48 and the rest 0

The only side effect of a wrapper element that I can see is possibly a bit of a structure change, but there would be a lot of benefits layout wise for vertical tabs. This could also solve the issue @alisonjoseph brought up where I am using percentages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just confirming the above that adding a wrapper with styles such as:

.#{$prefix}--tabs-wrapper {
    display: flex;
  }

then would remove the need for using javascript and css would automatically handle the heights. If both the default and vertical tabs have this wrapper though then there would need to be some javascript to handle when to apply display: flex or not to handle the different layouts for vertical and default

@kingtraceyj
Copy link
Member

@alisonjoseph the design intent is for the tablist and tab panel to be grid-aligned
-tablist 4 columns at max, x-large, and large breakpoints
-tablist 2 columns at Medium breakpoint
-tablist turns into contained tabs at small breakpoint

@tay1orjones i think that you are right in that is is (or will be) an accessibility violation if focus is obscured so we must keep the focused/active tab in view.

@ariellalgilmore
Copy link
Member Author

closing this PR in favor for: #16738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants