From ac6b54322ceccd782b640cc5a62335c1b369d1db Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 22 Feb 2018 09:27:49 +0100 Subject: [PATCH] MOBILE-2327 core: Destroy buttons moved by core-navbar-buttons --- .../messages/pages/discussion/discussion.html | 2 +- .../navbar-buttons/navbar-buttons.ts | 70 +++++++++++++------ src/providers/utils/dom.ts | 12 +++- 3 files changed, 60 insertions(+), 24 deletions(-) diff --git a/src/addon/messages/pages/discussion/discussion.html b/src/addon/messages/pages/discussion/discussion.html index 8589244d0..3b2e2db08 100644 --- a/src/addon/messages/pages/discussion/discussion.html +++ b/src/addon/messages/pages/discussion/discussion.html @@ -7,7 +7,7 @@ - + diff --git a/src/components/navbar-buttons/navbar-buttons.ts b/src/components/navbar-buttons/navbar-buttons.ts index b56416cbf..c9e1a8d30 100644 --- a/src/components/navbar-buttons/navbar-buttons.ts +++ b/src/components/navbar-buttons/navbar-buttons.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Component, Input, OnInit, ContentChildren, ElementRef, QueryList } from '@angular/core'; +import { Component, Input, OnInit, OnDestroy, ContentChildren, ElementRef, QueryList } from '@angular/core'; import { Button } from 'ionic-angular'; import { CoreLoggerProvider } from '../../providers/logger'; import { CoreDomUtilsProvider } from '../../providers/utils/dom'; @@ -26,10 +26,12 @@ import { CoreDomUtilsProvider } from '../../providers/utils/dom'; * * You can use the [hidden] input to hide all the inner buttons if a certain condition is met. * + * IMPORTANT: Do not use *ngIf in the buttons inside this component, it can cause problems. Please use [hidden] instead. + * * Example usage: * * - * * @@ -38,33 +40,27 @@ import { CoreDomUtilsProvider } from '../../providers/utils/dom'; selector: 'core-navbar-buttons', template: '' }) -export class CoreNavBarButtonsComponent implements OnInit { +export class CoreNavBarButtonsComponent implements OnInit, OnDestroy { protected BUTTON_HIDDEN_CLASS = 'core-navbar-button-hidden'; // If the hidden input is true, hide all buttons. @Input('hidden') set hidden(value: boolean) { this._hidden = value; - if (this._buttons) { - this._buttons.forEach((button: Button) => { - this.showHideButton(button); - }); - } + this.showHideAllElements(); } - // Get all the buttons inside this directive. + // Get all the ion-buttons inside this directive and apply the role bar-button. @ContentChildren(Button) set buttons(buttons: QueryList