Skip to content

[tabs] Modernize implementation#751

Merged
mj12albert merged 20 commits intomui:masterfrom
mj12albert:refactor/tabs-composite
Nov 25, 2024
Merged

[tabs] Modernize implementation#751
mj12albert merged 20 commits intomui:masterfrom
mj12albert:refactor/tabs-composite

Conversation

@mj12albert
Copy link
Copy Markdown
Member

@mj12albert mj12albert commented Oct 22, 2024

Summary

@mj12albert mj12albert added the component: tabs Changes related to the tabs component. label Oct 22, 2024
@mui-bot
Copy link
Copy Markdown

mui-bot commented Oct 22, 2024

Netlify deploy preview

https://deploy-preview-751--base-ui.netlify.app/

Generated by 🚫 dangerJS against ab269fd

@mj12albert mj12albert force-pushed the refactor/tabs-composite branch 4 times, most recently from 4dbf848 to 16c8fbb Compare October 28, 2024 09:52
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch from 16c8fbb to 683f8a9 Compare November 1, 2024 13:06
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch 4 times, most recently from c31706a to 5a7f24f Compare November 13, 2024 16:35
@mj12albert

This comment was marked as outdated.

}

if (nextIndex !== activeIndex && !isIndexOutOfBounds(elementsRef, nextIndex)) {
event.stopPropagation();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@atomiks Why is stopPropagation() needed here, and is it ever ok to force propagate it? This breaks a test

Given this structure:

<Tabs.Root onKeyDown={handleKeyDown}>
  <Tabs.List>
    <Tabs.Tab value={0} />
    <Tabs.Tab value={1} />
  </Tabs.List>
  {/* tab panels */}
</Tabs.Root>

Tabs.List is a CompositeRoot, so on arrow keys, the event doesn't propagate and handleKeyDown doesn't get called

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not certain on that. It may not be necessary in most cases

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OK ~ let's let it propagate by default, but I've put a param around it just in case:

if (stopEventPropagation) {
  event.stopPropagation();
}

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 19, 2024
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch from 46d11b3 to 17e3dcc Compare November 19, 2024 09:16
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 19, 2024
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch from 17e3dcc to bc1840f Compare November 19, 2024 09:21
@mj12albert mj12albert changed the title [tabs] Replace useCompound with Composite [tabs] Modernize implementation Nov 19, 2024
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch from 55e7dd5 to 353f95a Compare November 19, 2024 13:40
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 19, 2024
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch from 353f95a to 7bd5663 Compare November 19, 2024 13:44
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 19, 2024
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch 3 times, most recently from a2a0bfe to f00fd3d Compare November 20, 2024 12:38
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 20, 2024
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch from f00fd3d to 430bfb9 Compare November 20, 2024 15:46
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 20, 2024
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch 2 times, most recently from 26bba8c to 65b1053 Compare November 22, 2024 13:28
@mj12albert mj12albert force-pushed the refactor/tabs-composite branch from 65b1053 to ab269fd Compare November 23, 2024 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: tabs Changes related to the tabs component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants