Skip to content

Comments

Fix help text and error IDs for aria-describedby#746

Merged
dyve merged 4 commits intozostera:mainfrom
xi:fix-error-aria-describedby
May 4, 2025
Merged

Fix help text and error IDs for aria-describedby#746
dyve merged 4 commits intozostera:mainfrom
xi:fix-error-aria-describedby

Conversation

@xi
Copy link
Contributor

@xi xi commented Mar 3, 2025

Django recently started using aria-describedby to associate form fields first with their help texts, and later also with error messages.

In #716, django-bootstrap5 was adapted to also include those the necessary IDs in templates.

aria-describedby for fields can have different values:

  • "{field.auto_id}_helptext"
  • "{field.auto_id}_error"
  • both of them
  • a user defined value that is left unchanged

The approach in #716 was to use the value from aria-describedby for the ID of the help text. Unfortunately, this only works in the first case.

So I propose to solve this the same way the django templates solve this and just hardcode the IDs.

@xi xi force-pushed the fix-error-aria-describedby branch from 53ea6b5 to dba5fc0 Compare March 3, 2025 12:08
Django recently started using `aria-describedby` to associate form
fields first with their help texts, and later also with error messages.

In zostera#716, django-bootstrap5 was adapted to also include those the
necessary IDs in templates.

`aria-describedby` for fields can have different values:

-   `"{field.auto_id}_helptext"`
-   `"{field.auto_id}_error"`
-   both of them
-   a user defined value that is left unchanged

The approach in zostera#716 was to use the value from `aria-describedby` for
the ID of the help text. Unfortunately, this only works in the first
case.

So I propose to solve this the same way the django templates solve this
and just hardcode the IDs.
@xi xi force-pushed the fix-error-aria-describedby branch from dba5fc0 to 2e5b167 Compare April 23, 2025 14:20
@xi xi force-pushed the fix-error-aria-describedby branch from 1e844e1 to 9f3fbe2 Compare April 23, 2025 14:49
@dyve
Copy link
Member

dyve commented May 3, 2025

Python 3.9 / Django 4.2 triggers an error, can you check that?

@xi
Copy link
Contributor Author

xi commented May 3, 2025

Done. I am a bit confused why the other 4.2 tests environments didn't fail, but it seems to work now.

@dyve dyve merged commit ce8ef0f into zostera:main May 4, 2025
21 checks passed
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