From 5c59f004b12768e67fdade58b8359ab11e34d1b0 Mon Sep 17 00:00:00 2001 From: Quentin Bellanger Date: Thu, 5 Sep 2024 16:18:37 +0200 Subject: [PATCH 01/11] Focus le champ d'erreur quand le statut est "Non conforme" (#766) * open accordion when status is not compliant and focus error field * remove useless import * remove unnecessary nextTick * Fix focus in NC textarea after disclose animation * a11y: Add sr-only info for NC checkbox label Tells user that focus is going to be moved automatically on the following textarea * update extra label after focus moves * update changelog --------- Co-authored-by: Yaacov --- CHANGELOG.md | 6 +++ .../audit/AuditGenerationCriterium.vue | 7 +++ .../audit/CriteriumNotCompliantAccordion.vue | 26 ++++++++++- .../src/components/audit/LazyAccordion.vue | 45 ++++++++++++------- .../src/components/ui/RadioGroup.vue | 3 +- 5 files changed, 68 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06619946..5aeff246 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Tous les changements notables de Ara sont documentés ici avec leur date, leur catégorie (nouvelle fonctionnalité, correction de bug ou autre changement) et leur pull request (PR) associée. +## 05/09/2024 + +### Nouvelles fonctionnalités 🚀 + +- Le champs "Erreur et recommandation" est automatiquement focus lorsque le critère est défini comme "Non conforme" ([#766](https://github.com/DISIC/Ara/pull/766)) + ## 24/07/2024 ### Autres changements ⚙️ diff --git a/confiture-web-app/src/components/audit/AuditGenerationCriterium.vue b/confiture-web-app/src/components/audit/AuditGenerationCriterium.vue index 8add83da..12a28680 100644 --- a/confiture-web-app/src/components/audit/AuditGenerationCriterium.vue +++ b/confiture-web-app/src/components/audit/AuditGenerationCriterium.vue @@ -40,6 +40,7 @@ const props = defineProps<{ const statuses: Array<{ label: string; + extraLabel?: string; value: CriteriumResultStatus; color?: RadioColor; }> = [ @@ -50,6 +51,8 @@ const statuses: Array<{ }, { label: formatStatus(CriteriumResultStatus.NOT_COMPLIANT), + extraLabel: + "Le focus se déplacera dans le champ « Erreur et recommandation »", value: CriteriumResultStatus.NOT_COMPLIANT, color: "red" }, @@ -128,6 +131,10 @@ function updateResultStatus(status: CriteriumResultStatus) { store .updateResults(props.auditUniqueId, [{ ...result.value, status }]) .then(() => { + if (status === CriteriumResultStatus.NOT_COMPLIANT) { + criteriumNotCompliantAccordion.value?.disclose(); + } + if ( store.everyCriteriumAreTested && !auditStore.currentAudit?.publicationDate diff --git a/confiture-web-app/src/components/audit/CriteriumNotCompliantAccordion.vue b/confiture-web-app/src/components/audit/CriteriumNotCompliantAccordion.vue index 5e643576..74cbf155 100644 --- a/confiture-web-app/src/components/audit/CriteriumNotCompliantAccordion.vue +++ b/confiture-web-app/src/components/audit/CriteriumNotCompliantAccordion.vue @@ -32,7 +32,7 @@ const emit = defineEmits<{ (e: "update:quickWin", payload: boolean): void; }>(); -defineExpose({ onFileRequestFinished }); +defineExpose({ onFileRequestFinished, disclose }); const userImpacts: Array<{ label: string; @@ -71,12 +71,35 @@ function handleDeleteFile(image: AuditFile) { function onFileRequestFinished() { fileUpload.value?.onFileRequestFinished(); } + +const lazyAccordionRef = ref>(); +const commentFieldRef = ref(); + +let hasJustBeenSetAsNotCompliant = false; + +async function disclose() { + const accordion = lazyAccordionRef.value?.accordionRef; + + hasJustBeenSetAsNotCompliant = true; + dsfr(accordion).accordionsGroup.members[0].disclose(); +} + +function lazyAccordionOpened() { + if (!hasJustBeenSetAsNotCompliant) { + return; + } + + commentFieldRef.value?.focus(); + hasJustBeenSetAsNotCompliant = false; +}