From a1a5d369a71828db922f4e455ee230be47f73740 Mon Sep 17 00:00:00 2001 From: Steven Mouret Date: Tue, 8 Jan 2019 15:42:22 +0100 Subject: [PATCH] Fix accessibility : Fix aria-describedby when using data-parsley-error-message - Add aria-hidden attribute on error wrapper --- src/parsley/ui.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/parsley/ui.js b/src/parsley/ui.js index a3084d07f..6006d7282 100644 --- a/src/parsley/ui.js +++ b/src/parsley/ui.js @@ -170,14 +170,20 @@ UI.Field = { .addClass('parsley-custom-error-message') ); + this._ui.$errorClassHandler.attr('aria-describedby', this._ui.errorsWrapperId); + return this._ui.$errorsWrapper .addClass('filled') + .attr('aria-hidden', 'false') .find('.parsley-custom-error-message') .html(this.options.errorMessage); } + this._ui.$errorClassHandler.removeAttr('aria-describedby'); + return this._ui.$errorsWrapper .removeClass('filled') + .attr('aria-hidden', 'true') .find('.parsley-custom-error-message') .remove(); } @@ -200,6 +206,7 @@ UI.Field = { .attr('aria-describedby', this._ui.errorsWrapperId); this._ui.$errorsWrapper .addClass('filled') + .attr('aria-hidden', 'false') .append( $(this.options.errorTemplate) .addClass('parsley-' + name) @@ -219,6 +226,7 @@ UI.Field = { .removeAttr('aria-describedby'); this._ui.$errorsWrapper .removeClass('filled') + .attr('aria-hidden', 'true') .find('.parsley-' + name) .remove(); },