Merge pull request #4174 from dpalou/MOBILE-4657

MOBILE-4657 tabs: Fix detection of nav bar buttons to hide
main
Alfonso Salces 2024-09-17 10:13:25 +02:00 committed by GitHub
commit df209b4071
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 6 deletions

View File

@ -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;
@ -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);
}
});
}