Skip to content

Commit

Permalink
Fix accessibility : Fix aria-describedby when using data-parsley-erro…
Browse files Browse the repository at this point in the history
…r-message - Add aria-hidden attribute on error wrapper
  • Loading branch information
stevenMouret authored and marcandre committed Oct 6, 2019
1 parent 04f744e commit a1a5d36
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/parsley/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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)
Expand All @@ -219,6 +226,7 @@ UI.Field = {
.removeAttr('aria-describedby');
this._ui.$errorsWrapper
.removeClass('filled')
.attr('aria-hidden', 'true')
.find('.parsley-' + name)
.remove();
},
Expand Down

0 comments on commit a1a5d36

Please sign in to comment.