Skip to content

Commit

Permalink
fix(tabs): selectedIndexChange do not emit first value
Browse files Browse the repository at this point in the history
  • Loading branch information
Enlcxx committed Jun 8, 2019
1 parent a73f773 commit 1ce4fe7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export class TabsWithLazyLoadingComponent {
readonly classes = this.theme.addStyleSheet(styles);
tabLoadTimes: Date[] = [];

constructor(
private theme: LyTheme2
) { }

getTime(index: number) {
if (!this.tabLoadTimes[index]) {
this.tabLoadTimes[index] = new Date();
Expand All @@ -24,8 +28,4 @@ export class TabsWithLazyLoadingComponent {
return this.tabLoadTimes[index];
}

constructor(
private theme: LyTheme2
) { }

}
5 changes: 4 additions & 1 deletion src/lib/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ mixinBg(
export class LyTabs extends LyTabsMixinBase implements OnChanges, OnInit, AfterViewInit, AfterContentInit, OnDestroy {
/** @docs-private */
readonly classes = this.theme.addStyleSheet(STYLES);
_selectedIndex = 0;
_selectedIndex: number;
_selectedBeforeIndex: number;
_selectedTab: LyTab | null;
_selectedBeforeTab: LyTab;
Expand Down Expand Up @@ -395,6 +395,9 @@ export class LyTabs extends LyTabsMixinBase implements OnChanges, OnInit, AfterV
}

ngOnInit() {
if (this.selectedIndex == null) {
this.selectedIndex = 0;
}
this.renderer.addClass(this.el.nativeElement, this.classes.root);
const tabsIndicatorEl = this.tabsIndicator.nativeElement;
this.renderer.addClass(tabsIndicatorEl, this.classes.tabsIndicator);
Expand Down

0 comments on commit 1ce4fe7

Please sign in to comment.