Browse Source

Ensure StreamField panels validation errors are visible (#10673)

...by rendering panels as expanded, regardless of the collapse
setting specified by the Wagtail implementor.

Fixes #8990 partially.
Storm B. Heg 1 năm trước cách đây
mục cha
commit
fef8c4ac3c

+ 1 - 0
CHANGELOG.txt

@@ -62,6 +62,7 @@ Changelog
  * Fix: Take user's permissions into account for image / document counts on the admin dashboard (Sage Abdullah)
  * Fix: Avoid N+1 queries in users index view (Tidiane Dia)
  * Fix: Use a theme-agnostic color token for read-only panels support in dark mode (Thibaud Colas)
+ * Fix: Ensure collapsible StreamBlocks expand as necessary to show validation errors (Storm Heg)
  * Docs: Document how to add non-ModelAdmin views to a `ModelAdminGroup` (Onno Timmerman)
  * Docs: Document how to add StructBlock data to a StreamField (Ramon Wenger)
  * Docs: Update ReadTheDocs settings to v2 to resolve urllib3 issue in linkcheck extension (Thibaud Colas)

+ 5 - 0
client/src/components/StreamField/blocks/BaseSequenceBlock.js

@@ -349,6 +349,11 @@ export class BaseSequenceChild extends EventEmitter {
 
   setError(error) {
     this.block.setError(error);
+
+    // If there is an error, the panel should be expanded always so the error is not obscured
+    if (error) {
+      toggleCollapsiblePanel(this.toggleElement, true);
+    }
   }
 
   focus(opts) {

+ 1 - 0
docs/releases/5.1.md

@@ -119,6 +119,7 @@ This feature was developed by Aman Pandey as part of the Google Summer of Code p
  * Take user's permissions into account for image / document counts on the admin dashboard (Sage Abdullah)
  * Avoid N+1 queries in users index view (Tidiane Dia)
  * Use a theme-agnostic color token for read-only panels support in dark mode (Thibaud Colas)
+ * Ensure collapsible StreamBlocks expand as necessary to show validation errors (Storm Heg)
 
 ### Documentation