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(tabs): default scroll-behavior: smooth not working #5499

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions tabs/internal/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
display: flex;
height: 100%;
overflow: inherit;
scroll-behavior: inherit;
scrollbar-width: inherit;
justify-content: space-between;
width: 100%;
}
Expand Down
7 changes: 5 additions & 2 deletions tabs/internal/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ export class Tabs extends LitElement {
const min = offset - scrollMargin;
const max = offset + extent - hostExtent + scrollMargin;
const to = Math.min(min, Math.max(max, scroll));
// TODO(b/299934312): improve focus smoothness
const behavior: ScrollBehavior = !this.focusedTab ? 'smooth' : 'instant';
// When a tab is focused, use 'auto' to use the CSS `scroll-behavior`. The
// default behavior is smooth scrolling. However, when there is not a tab
// focused on initialization, use 'instant' to immediately bring the focused
// tab into view.
const behavior: ScrollBehavior = !this.focusedTab ? 'instant' : 'auto';
this.tabsScrollerElement.scrollTo({behavior, top: 0, left: to});
}

Expand Down
Loading