]> BookStack Code Mirror - bookstack/commitdiff
Auto-expand collapsible sections if containing error
authorDan Brown <redacted>
Mon, 16 Dec 2019 13:27:17 +0000 (13:27 +0000)
committerDan Brown <redacted>
Mon, 16 Dec 2019 13:27:17 +0000 (13:27 +0000)
For #1693

resources/js/components/collapsible.js

index 464f394c1e7e42a8d1dc568c94568d53f1498819..a630f38f2a577591916f2e86796d8b796f4634a1 100644 (file)
@@ -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