-
Notifications
You must be signed in to change notification settings - Fork 319
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
Character count message should be placed correctly in markup without Javascript #1602
Comments
I think this would require us to add something to the textarea API that allows us to insert this inside the form-group. |
Yes, we’d need to add it to the textarea API and tweak the textarea macro template so that it can accept a hint which would render below In conclusion, I don't think we should do this - it's a bit of an irregularity (ideally the JS wouldn’t need to move the markup around) but it's not causing any problems and if anything, adding it into the textarea API could actually lead to it being misused in other contexts. Tempted to just close this issue but will leave it open for a bit longer for any other comments. |
If we made this change, would that mean that the hint would appear below the text area for users who have turned off JavaScript? That would seem like surprising/wrong behaviour to me. |
No – the hint and error message are standard, there's nothing special going on with them. However, at the minute the character count 'info message' ('You can enter up to X characters', which is separate to the hint) is outside of the form group in the component HTML, and the JS moves it inside the form group. That means that when JS is disabled and the input is in the error state, the info message appears outside of it: It also means we have to 'move' the margin that's normally applied to the form group for all (?) other form inputs from the form group to the character count wrapper: govuk-frontend/src/govuk/components/character-count/_index.scss Lines 7 to 14 in 133ea4f
(Otherwise there would be a 30px margin between the form group and the info message, and only a small margin between the info message and the next component) I think the pros to fixing this are:
However as Hanna as pointed out the downside is we need to extend the textarea's API to allow the passing of content to be added before the closing tag of the form group div. I don't think it'd have to be specific to hints though – we could allow e.g. an 'arbitrary' |
This is now ready to review as part of #4566 |
The character count Javascript moves the count message ("You have x characters remaining") in the DOM to be inside
govuk-form-group
. This was probably useful when the message markup was created dynamically. However this functionality is now redundant. The JS should be removed and the count message markup placed insidegovuk-form-group
in the component markup. This is so that we don't unnecessarily rely on Javascript for the correct order of DOM elements.It’s important that the count message markup is inside
govuk-form-group
so that it gets wrapped within the error block (see screen grab below).We put off making this change this in #1594 as it's a breaking change.
Done when
Details of breaking change
The text was updated successfully, but these errors were encountered: