Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement soft required validation #726

Merged
merged 5 commits into from
Oct 29, 2024

Conversation

sergei-maertens
Copy link
Member

Closes open-formulieren/open-forms#4546

This went better than I had anticipated.

  • Implement 'content' component variant for the soft required validation errors
  • Styled it as a common/regular warning alert
  • Added escape hatches for background color/font color/font-weight in case it needs to look different from a regular alert
  • Ensured accessibility (linked list header, form fields refer back to content)
  • Added stories and unit tests
  • Checked the template interpolation/rendering for XSS, seems to be okay.

Final tasks to wrap this up:

  • Update formio translations in the backend
  • Review documentation if anything extra is needed

@sergei-maertens sergei-maertens force-pushed the feature/4546-soft-required-validation branch from a5507e2 to f3a8030 Compare October 28, 2024 16:49
Copy link

codecov bot commented Oct 28, 2024

Codecov Report

Attention: Patch coverage is 93.93939% with 4 lines in your changes missing coverage. Please review.

Project coverage is 78.08%. Comparing base (177f1cc) to head (8b339c5).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/formio/components/SoftRequiredErrors.js 89.47% 2 Missing ⚠️
src/formio/utils.js 94.44% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #726      +/-   ##
==========================================
+ Coverage   77.90%   78.08%   +0.18%     
==========================================
  Files         237      238       +1     
  Lines        4888     4938      +50     
  Branches     1337     1348      +11     
==========================================
+ Hits         3808     3856      +48     
- Misses       1045     1048       +3     
+ Partials       35       34       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

});

return `
<div id="${this.id}-content" class="utrecht-alert utrecht-alert--warning openforms-soft-required-errors">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add some context for users with a visual disability:

Suggested change
<div id="${this.id}-content" class="utrecht-alert utrecht-alert--warning openforms-soft-required-errors">
<div id="${this.id}-content" class="utrecht-alert utrecht-alert--warning openforms-soft-required-errors" role="alert">

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/alert_role:

The alert role is for important, and usually time-sensitive, information.

I don't find this time sensitive, especially because it's also displayed at the beginning of a form step that is yet to be filled out.

The alert role should only be used for information that requires the user's immediate attention, for example:

This is not the case - it becomes important once you are about to submit the form.

I think the role="status" is more appropriate: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/status_role

…atic variant

Dummy set up to render the template content of a soft required errors
component. This is set up so that every form change triggers a re-render
of the content, which should hopefully help in detecting the empty
fields with softRequired validation enabled.
On each render, the softRequiredErrors component checks which components
have 'empty' values and extracts their labels. Only if there are empty
components is the error message displayed.
…tion errors and input are linked in an accessible way

Similar to the validation error linking for hard errors, we relate the
content div(s) describing the soft-required validation errors.
…quired errors component

This enables it to be customized via NL DS design tokens, and provides
some escape hatches to make it different from the standard warning
alert appearance.
@sergei-maertens sergei-maertens force-pushed the feature/4546-soft-required-validation branch from f3a8030 to f19c49e Compare October 29, 2024 16:59
Added a single helper to set the desired list of aria-describedby IDs
in the element attribute, for each element.
@sergei-maertens sergei-maertens force-pushed the feature/4546-soft-required-validation branch from f19c49e to 8b339c5 Compare October 29, 2024 17:18
@sergei-maertens sergei-maertens merged commit 6352de4 into main Oct 29, 2024
15 checks passed
@sergei-maertens sergei-maertens deleted the feature/4546-soft-required-validation branch October 29, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "soft required" validation/hint to document uploads component
2 participants