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

fix: extra arrow in tab component on resize #16652

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/react/src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,10 @@ function TabList({
});

useEffect(() => {
//adding 1 in calculation for firefox support
setIsNextButtonVisible(
ref.current
? scrollLeft + buttonWidth + ref.current.clientWidth <
? scrollLeft + buttonWidth + ref.current.clientWidth + 1 <
ref.current.scrollWidth
: false
);
Expand All @@ -450,7 +451,7 @@ function TabList({
setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth);
}
}
}, [scrollLeft, children, dismissable]);
}, [scrollLeft, children, dismissable, isScrollable]);

useEffectOnce(() => {
if (tabs.current[selectedIndex]?.disabled) {
Expand All @@ -467,12 +468,14 @@ function TabList({

useIsomorphicEffect(() => {
if (ref.current) {
setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth);
//adding 1 in calculation for firefox support
setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
}

function handler() {
if (ref.current) {
setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth);
//adding 1 in calculation for firefox support
setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
}
}

Expand Down
9 changes: 5 additions & 4 deletions packages/styles/scss/components/tabs/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
}

.#{$prefix}--tab--overflow-nav-button svg {
z-index: 2;
fill: $icon-primary;
}

Expand Down Expand Up @@ -155,16 +156,16 @@
.#{$prefix}--tab--overflow-nav-button--previous::before {
position: absolute;
z-index: 1;
background: linear-gradient(to left, rgba(255, 255, 255, 0), $background);
background: $background;
block-size: 100%;
content: '';
inline-size: $spacing-03;
inset-inline-end: -$spacing-03;
inline-size: $spacing-08;
inset-inline-end: 0;
}

&.#{$prefix}--tabs--contained
.#{$prefix}--tab--overflow-nav-button--previous::before {
background-image: linear-gradient(
background: linear-gradient(
to left,
rgba(255, 255, 255, 0),
$layer-accent
Expand Down
Loading