Skip to content

Commit 615d861

Browse files
Elliott Marquezcopybara-github
authored andcommitted
fix(tab): fix race condition on safari
fixes #1867 PiperOrigin-RevId: 334940248
1 parent 7bb04b9 commit 615d861

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2525
- `--mdc-menu-max-height` to set max height on menu
2626
- `tab`
2727
- export for `TabInteractionEventDetail`
28+
- fix race condition on safari
2829

2930
### Changed
3031

packages/tab/mwc-tab-base.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ export class TabBase extends BaseElement {
8181
* onTransitionEnd (needed?)
8282
*/
8383

84-
@query('mwc-tab-indicator') private _tabIndicator!: HTMLElement;
85-
8684
@query('.mdc-tab__content') private _contentElement!: HTMLElement;
8785

8886
private _handleClick() {
@@ -159,11 +157,14 @@ export class TabBase extends BaseElement {
159157
...addHasRemoveClass(this.mdcRoot),
160158
setAttr: (attr: string, value: string) =>
161159
this.mdcRoot.setAttribute(attr, value),
162-
activateIndicator: (previousIndicatorClientRect: ClientRect) =>
163-
(this._tabIndicator as TabIndicator)
164-
.activate(previousIndicatorClientRect),
165-
deactivateIndicator: () =>
166-
(this._tabIndicator as TabIndicator).deactivate(),
160+
activateIndicator: async (previousIndicatorClientRect: ClientRect) => {
161+
await this.tabIndicator.updateComplete;
162+
this.tabIndicator.activate(previousIndicatorClientRect);
163+
},
164+
deactivateIndicator: async () => {
165+
await this.tabIndicator.updateComplete;
166+
this.tabIndicator.deactivate();
167+
},
167168
notifyInteracted: () =>
168169
this.dispatchEvent(new CustomEvent<TabInteractionEventDetail>(
169170
MDCTabFoundation.strings.INTERACTED_EVENT, {

0 commit comments

Comments
 (0)