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

Replace required asterisk with text label. #1039

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

kimisgold
Copy link
Member

The current means of marking required fields is an asterisk, often applied as a pseudo element. It is inaccessible to screen readers, so this pull request replaces the asterisk with a styled text label that reads "required".

@kimisgold kimisgold requested a review from zerocrates November 21, 2024 15:27
@zerocrates
Copy link
Member

This had one issue which was that you had to turn off escaping to get the extra label markup in there, with the side effect that now the label itself won't be escaped.

I think the way we'd have to go with this is to make our own Label decorator that can include this markup.

This decorator escapes the label content itself while allowing required field markup to render.
@kimisgold
Copy link
Member Author

I extended the default label decorator, and overwrote some of the functions so that the label contents are escaped by default or if the option is set to true. First getLabel() no longer adds the required prefix or suffix, just retrieves the label contents. In render(), the label contents can be escaped before having the non-escaped required content attached using handleRequired(). The label contents and required markup then get passed to formLabel() with escaping enabled.

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.

2 participants