From 447612abdfcc16cecb1d168a3434e8b1158bf55e Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Wed, 2 Feb 2022 18:03:24 +0100 Subject: [PATCH 1/2] fix a11y-8.9.1 no p tag when Champ text with no value --- app/helpers/string_to_html_helper.rb | 1 + app/views/shared/dossiers/_champ_row.html.haml | 2 +- spec/helpers/string_to_html_helper_spec.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/string_to_html_helper.rb b/app/helpers/string_to_html_helper.rb index 8806863f6..8fc99684f 100644 --- a/app/helpers/string_to_html_helper.rb +++ b/app/helpers/string_to_html_helper.rb @@ -1,5 +1,6 @@ module StringToHtmlHelper def string_to_html(str, wrapper_tag = 'p') + return nil if str.blank? html_formatted = simple_format(str, {}, { wrapper_tag: wrapper_tag }) with_links = Anchored::Linker.auto_link(html_formatted, target: '_blank', rel: 'noopener') sanitize(with_links, attributes: ['target', 'rel', 'href']) diff --git a/app/views/shared/dossiers/_champ_row.html.haml b/app/views/shared/dossiers/_champ_row.html.haml index 4392289d8..edb7f0788 100644 --- a/app/views/shared/dossiers/_champ_row.html.haml +++ b/app/views/shared/dossiers/_champ_row.html.haml @@ -57,7 +57,7 @@ - when TypeDeChamp.type_champs.fetch(:number) = number_with_html_delimiter(c.to_s) - else - = format_text_value(c.to_s) + = format_text_value(c.to_s) unless c.blank? - if c.type_champ != TypeDeChamp.type_champs.fetch(:header_section) %td.updated-at diff --git a/spec/helpers/string_to_html_helper_spec.rb b/spec/helpers/string_to_html_helper_spec.rb index 847b6def7..545bc0cbb 100644 --- a/spec/helpers/string_to_html_helper_spec.rb +++ b/spec/helpers/string_to_html_helper_spec.rb @@ -28,7 +28,7 @@ RSpec.describe StringToHtmlHelper, type: :helper do context "with empty decription" do let(:description) { nil } - it { is_expected.to eq('

') } + it { is_expected.to eq nil } end context "with a bad script" do From b80ec845521fd5ac478f9d23ccf173701b03988c Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Wed, 2 Feb 2022 18:04:41 +0100 Subject: [PATCH 2/2] fix a11y-8.9.1 for attachement description error --- app/views/shared/attachment/_edit.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/shared/attachment/_edit.html.haml b/app/views/shared/attachment/_edit.html.haml index d61f555b9..124680296 100644 --- a/app/views/shared/attachment/_edit.html.haml +++ b/app/views/shared/attachment/_edit.html.haml @@ -29,6 +29,7 @@ %p.attachment-error-title Une erreur s’est produite pendant l’envoi du fichier. %p.attachment-error-description + Une erreur inconnue s'est produite pendant l'envoi du fichier = button_tag type: 'button', class: 'button attachment-error-retry', data: { 'input-target': ".attachment-input-#{attachment_id}" } do %span.icon.retry Ré-essayer