Skip to content

Commit

Permalink
MOBILE-4657 tabs: Fix detection of nav bar buttons to hide
Browse files Browse the repository at this point in the history
All course option site plugins use the same page name, so using page name to check if a page is selected caused problems. It's better to use the tab ID
  • Loading branch information
dpalou committed Sep 17, 2024
1 parent 90a356f commit 6290fb9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/core/components/tabs-outlet/tabs-outlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class CoreTabsOutletComponent extends CoreTabsBaseComponent<CoreTabsOutle
this.tabSelected(tab, tabIndex);
}

this.showHideNavBarButtons(stackEvent.enteringView.element.tagName);
this.showHideNavBarButtons();
}));
this.subscriptions.push(this.ionTabs.outlet.activateEvents.subscribe(() => {
this.lastActiveComponent = this.ionTabs.outlet.component;
Expand Down Expand Up @@ -206,17 +206,15 @@ export class CoreTabsOutletComponent extends CoreTabsBaseComponent<CoreTabsOutle
* Get all child core-navbar-buttons and show or hide depending on the page state.
* We need to use querySelectorAll because ContentChildren doesn't work with ng-template.
* https://github.com/angular/angular/issues/14842
*
* @param activatedPageName Activated page name.
*/
protected showHideNavBarButtons(activatedPageName: string): void {
protected showHideNavBarButtons(): void {
const elements = this.ionTabs.outlet.nativeEl.querySelectorAll('core-navbar-buttons');
elements.forEach((element) => {
const instance = CoreDirectivesRegistry.resolve(element, CoreNavBarButtonsComponent);

if (instance) {
const pagetagName = element.closest('.ion-page')?.tagName;
instance.forceHide(activatedPageName != pagetagName);
const pageTabId = element.closest('.ion-page')?.id;
instance.forceHide(this.selected !== pageTabId);
}
});
}
Expand Down

0 comments on commit 6290fb9

Please sign in to comment.