Skip to content

NOW MANAGED ON CODEBERG

Auto-expand collapsible sections if containing error

Dan Brownb93f8a4d4680
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