Fix max length bug

This commit is contained in:
zandercymatics 2024-04-04 13:37:36 -06:00
parent 1e4be56e8e
commit 6728826c0b
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 6 additions and 11 deletions

View file

@ -33,6 +33,7 @@ class DomainAddUserForm(forms.Form):
email = forms.EmailField( email = forms.EmailField(
label="Email", label="Email",
max_length=None,
error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")},
validators=[ validators=[
MaxLengthValidator( MaxLengthValidator(
@ -300,6 +301,7 @@ class DomainSecurityEmailForm(forms.Form):
security_email = forms.EmailField( security_email = forms.EmailField(
label="Security email (optional)", label="Security email (optional)",
max_length=None,
required=False, required=False,
error_messages={ error_messages={
"invalid": str(SecurityEmailError(code=SecurityEmailErrorCodes.BAD_DATA)), "invalid": str(SecurityEmailError(code=SecurityEmailErrorCodes.BAD_DATA)),

View file

@ -369,6 +369,7 @@ class AuthorizingOfficialForm(RegistrarForm):
) )
email = forms.EmailField( email = forms.EmailField(
label="Email", label="Email",
max_length=None,
error_messages={"invalid": ("Enter an email address in the required format, like name@example.com.")}, error_messages={"invalid": ("Enter an email address in the required format, like name@example.com.")},
validators=[ validators=[
MaxLengthValidator( MaxLengthValidator(
@ -572,6 +573,7 @@ class YourContactForm(RegistrarForm):
) )
email = forms.EmailField( email = forms.EmailField(
label="Email", label="Email",
max_length=None,
error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")},
validators=[ validators=[
MaxLengthValidator( MaxLengthValidator(
@ -633,6 +635,7 @@ class OtherContactsForm(RegistrarForm):
) )
email = forms.EmailField( email = forms.EmailField(
label="Email", label="Email",
max_length=None,
error_messages={ error_messages={
"required": ("Enter an email address in the required format, like name@example.com."), "required": ("Enter an email address in the required format, like name@example.com."),
"invalid": ("Enter an email address in the required format, like name@example.com."), "invalid": ("Enter an email address in the required format, like name@example.com."),

View file

@ -79,17 +79,7 @@ error messages, if necessary.
{% if widget.attrs.maxlength %} {% if widget.attrs.maxlength %}
<span <span
id="{{ widget.attrs.id }}__message" id="{{ widget.attrs.id }}__message"
{% comment %} class="usa-character-count__message"
Many USWDS scripts actually rely on this field existing when using maxlength (even when implied).
Without it, our javascript breaks as the base script they are using has poor error handling.
To maintain consistency and to avoid doing massive overrides, we can just simply hide this field.
This is a workaround but I would argue the tradeoff here makes sense.
{% endcomment %}
{% if not show_max_length %}
aria-hidden="true"
{% endif %}
class="usa-character-count__message {% if not show_max_length %} display-none {% endif %}"
aria-live="polite" aria-live="polite"
> >
You can enter up to {{ widget.attrs.maxlength }} characters You can enter up to {{ widget.attrs.maxlength }} characters