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

[core] fix(Tabs): don't animate tab indicator on first render #4275

Merged
merged 2 commits into from
Aug 11, 2020
Merged
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
8 changes: 6 additions & 2 deletions packages/core/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class Tabs extends AbstractPureComponent2<ITabsProps, ITabsState> {
}

public componentDidMount() {
this.moveSelectionIndicator();
this.moveSelectionIndicator(false);
}

public componentDidUpdate(prevProps: ITabsProps, prevState: ITabsState) {
Expand Down Expand Up @@ -266,7 +266,7 @@ export class Tabs extends AbstractPureComponent2<ITabsProps, ITabsState> {
* Calculate the new height, width, and position of the tab indicator.
* Store the CSS values so the transition animation can start.
*/
private moveSelectionIndicator() {
private moveSelectionIndicator(animate = true) {
if (this.tablistElement == null || !this.props.animate) {
return;
}
Expand All @@ -282,6 +282,10 @@ export class Tabs extends AbstractPureComponent2<ITabsProps, ITabsState> {
transform: `translateX(${Math.floor(offsetLeft)}px) translateY(${Math.floor(offsetTop)}px)`,
width: clientWidth,
};
adidahiya marked this conversation as resolved.
Show resolved Hide resolved

if (!animate) {
indicatorWrapperStyle.transition = "none";
}
}
this.setState({ indicatorWrapperStyle });
}
Expand Down