From e750ef2c6e532bdc31452ecd32ea73e6cda26a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 29 Mar 2022 13:04:19 +0200 Subject: [PATCH] MOBILE-3833 collapsible: Fix disabled collapsible header on error --- src/core/directives/collapsible-header.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/directives/collapsible-header.ts b/src/core/directives/collapsible-header.ts index fb15f6445..1cb15b1d6 100644 --- a/src/core/directives/collapsible-header.ts +++ b/src/core/directives/collapsible-header.ts @@ -208,7 +208,11 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest this.expandedHeader = this.page?.querySelector('ion-item[collapsible]') ?? undefined; if (!this.expandedHeader) { + this.enabled = false; + this.setEnabled(this.enabled); + throw new Error('[collapsible-header] Couldn\'t initialize expanded header'); + } this.expandedHeader.classList.add('collapsible-header-expanded'); @@ -384,11 +388,11 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest * @param enable True to enable, false otherwise */ async setEnabled(enable: boolean): Promise { - if (!this.page || !this.content) { + if (!this.page) { return; } - if (enable) { + if (enable && this.content) { const contentScroll = await this.content.getScrollElement(); // Do nothing, since scroll has already started on the page.