From fef8c4ac3c40f918758b6a08bf5523cf85293443 Mon Sep 17 00:00:00 2001 From: "Storm B. Heg" Date: Thu, 13 Jul 2023 10:23:03 +0200 Subject: [PATCH] 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. --- CHANGELOG.txt | 1 + .../src/components/StreamField/blocks/BaseSequenceBlock.js | 5 +++++ docs/releases/5.1.md | 1 + 3 files changed, 7 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f0afd18152..637c6c72e3 100644 --- a/CHANGELOG.txt +++ b/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) diff --git a/client/src/components/StreamField/blocks/BaseSequenceBlock.js b/client/src/components/StreamField/blocks/BaseSequenceBlock.js index 64a3dd0cfe..1f76d84814 100644 --- a/client/src/components/StreamField/blocks/BaseSequenceBlock.js +++ b/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) { diff --git a/docs/releases/5.1.md b/docs/releases/5.1.md index ff170f1d4e..7ce0aa0cec 100644 --- a/docs/releases/5.1.md +++ b/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