Skip to content

[TabScrollButton] Fix StartScrollButtonIcon/EndScrollButtonIcon swap in RTL#48502

Open
starboyvarun wants to merge 1 commit intomui:masterfrom
starboyvarun:39296-tabs-scroll-button-rtl-slots
Open

[TabScrollButton] Fix StartScrollButtonIcon/EndScrollButtonIcon swap in RTL#48502
starboyvarun wants to merge 1 commit intomui:masterfrom
starboyvarun:39296-tabs-scroll-button-rtl-slots

Conversation

@starboyvarun
Copy link
Copy Markdown
Contributor

Summary

Fixes #39296.

In RTL layout, Tabs.js passes direction="right" to the start scroll button and direction="left" to the end scroll button (the directions are flipped so the arrows point the right way visually). However, TabScrollButton selected which slot icon to render based solely on direction === 'left' with no awareness of RTL. This caused custom StartScrollButtonIcon and EndScrollButtonIcon slot overrides to appear on the wrong sides in RTL mode.

Fix: Change the icon selection to (direction === 'left') !== isRtl. This XOR keeps LTR behavior identical and inverts the slot mapping in RTL so StartScrollButtonIcon always renders in the start scroll button and EndScrollButtonIcon always renders in the end scroll button, regardless of direction.

Test plan

  • New RTL tests: StartScrollButtonIcon renders for direction="right" in RTL
  • New RTL tests: EndScrollButtonIcon renders for direction="left" in RTL
  • Existing direction LTR tests still pass

…in RTL (mui#39296)

In RTL layout, Tabs.js passes `direction=right` to the start scroll button
and `direction=left` to the end scroll button (flipped from LTR). However,
TabScrollButton chose which slot icon to render based solely on `direction`,
without accounting for the RTL flip. This caused custom `StartScrollButtonIcon`
and `EndScrollButtonIcon` slot overrides to appear on the wrong sides in RTL.

Fix: use `(direction === left) !== isRtl` to select the icon slot so that in
RTL the semantic start/end mapping follows the visual flip applied by Tabs.
@code-infra-dashboard
Copy link
Copy Markdown

Deploy preview

https://deploy-preview-48502--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+4B(0.00%) 🔺+3B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

Copy link
Copy Markdown
Member

@mj12albert mj12albert left a comment

Choose a reason for hiding this comment

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

This breaks vertical orientation

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.

[Tabs][material-ui] Scroll buttons in RTL mode not using slots component

2 participants