Skip to content

Commit

Permalink
fix(core): incorrect emitting of tab change events (SAP#8637)
Browse files Browse the repository at this point in the history
* fix(core): incorrect emitting of tab change events

* fix(core): emit tab event after it has been set to active

* fix(core): test fix
  • Loading branch information
mikerodonnell89 authored Sep 8, 2022
1 parent d6d7d5c commit d15b85f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions e2e/wdio/core/tests/dynamic-page.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ describe('dynamic side content test suite', () => {
openPage(tabsExample, 1);
scrollIntoView(tabsContent, 1);
pause(1500);
expect(getElementClass(tab)).toContain(
expect(getElementClass(tab, 1)).toContain(
'is-selected',
'tab is not highlited as selected after scroll to content'
);
expect(getElementClass(tab, 1)).not.toContain('is-selected', 'tab is selected, but should not');
expect(getElementClass(tab, 0)).not.toContain('is-selected', 'tab is selected, but should not');
expect(getElementClass(tab, 2)).not.toContain('is-selected', 'tab is selected, but should not');
});

Expand Down
7 changes: 5 additions & 2 deletions libs/core/src/lib/tabs/tab-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@ export class TabListComponent implements AfterContentInit, AfterViewInit, OnDest

/** @hidden */
_highlightActiveTab({ id }: HTMLElement): void {
const tab = this._tabArray.find((_tab) => _tab.id === id);
const tab = this._tabArray.find((_tab) => _tab.panel._panelId === id);
if (tab) {
const _tabWasActive = tab.active;
this._activateStackedTab(tab.panel, false);
this.selectedTabChange.emit(tab.panel);
if (!_tabWasActive) {
this.selectedTabChange.emit(tab.panel);
}
}
}

Expand Down

0 comments on commit d15b85f

Please sign in to comment.