From b93f8a4d4680cfe34e3b64db95f0f9683152c22a Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Mon, 16 Dec 2019 13:27:17 +0000 Subject: [PATCH] Auto-expand collapsible sections if containing error For #1693 --- resources/js/components/collapsible.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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