From: Dan Brown Date: Mon, 16 Dec 2019 13:27:17 +0000 (+0000) Subject: Auto-expand collapsible sections if containing error X-Git-Tag: v0.28.0~1^2~32 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/b93f8a4d4680cfe34e3b64db95f0f9683152c22a Auto-expand collapsible sections if containing error For #1693 --- diff --git a/resources/js/components/collapsible.js b/resources/js/components/collapsible.js index 464f394c1..a630f38f2 100644 --- a/resources/js/components/collapsible.js +++ b/resources/js/components/collapsible.js @@ -12,8 +12,8 @@ class Collapsible { this.content = elem.querySelector('[collapsible-content]'); if (!this.trigger) return; - this.trigger.addEventListener('click', this.toggle.bind(this)); + this.openIfContainsError(); } open() { @@ -36,6 +36,13 @@ class Collapsible { } } + openIfContainsError() { + const error = this.content.querySelector('.text-neg'); + if (error) { + this.open(); + } + } + } export default Collapsible; \ No newline at end of file