-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Fixed #34643 -- Move admin form labels to a more accessible place #16975
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
base: main
Are you sure you want to change the base?
Conversation
I've updated the failing tests. @felixxm is the approach of the fix okay? |
I could be wrong but I thought @thibaudcolas' recommendation was to look at just making the small-width responsive CSS be used for all widths. I didn't think any HTML changes were required with this? 🤔 |
You're right, my apologies! I read that comment, but it slipped out of my mind when I was working on the patch 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a vague feeling from my previous work trying to get this stuff aligned after changing things that actually a lot of CSS can be removed that supports aligning stuff in different cases. But if I'm right on that I'm not sure it really needs to be done here.
I didn't do any review (yet?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @hrushikeshrv, apologies for the delay here. I made a quick review locally, and found two issues with help text alignment:
One when using the wide
fieldset class used by default in the user add admin:

And another using RTL:

You can test this by setting your LANGUAGE_CODE
to e.g. he
.
Thanks for the review, @knyghty 👍🏻 I also found these lines in However, now that form labels are placed above their respective inputs, validation errors on fields are displayed above the labels, like this - ![]() IMO, we should move these errors to be below the inputs and above the help text (if any). |
@hrushikeshrv thanks for bringing this up, it's indeed in a bad place. I talked with @thibaudcolas a bit and we suggest following gov.uk and putting it between the help text and the input: https://design-system.service.gov.uk/components/error-message/ It might also be a good time to move the help text to the same place (above the input, rather than below). I also wonder if the |
@hrushikeshrv my feeling is we should just remove the label widths. They might be excessively long in some cases I suppose, but I feel like intuitively they should take up the full width of the content. If it feels too long for very verbose labels, maybe that's a great impetus to increase the font size (in another PR). For .aligned, maybe, I didn't look into it too much. Removing widths is probably enough for here and we can do any clean up, again, in another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hrushikeshrv, again apologies for the delay here.
I noticed another problem we'll face here. It's possible that you can define multiple fields on the same line. The upshots of this:
- We need to handle it, by making sure it works (e.g. we'd have a column per field, but the label / field / help text / etc. is still in a single column). I didn't test this yet myself.
- The wide class is probably still of value here.
@knyghty I tested defining multiple fields on the same line, and it was indeed not working. I've handled that case so it now works as expected. ![]() Regarding the |
I will do some testing myself but I think otherwise this is ready for a review from someone other than me. I've updated the flags on the ticket. Release notes are probably also required. |
Thanks @knyghty. I've fixed the merge conflicts as well. This is my first time writing release notes so I had a few questions. Should I write the release notes in |
Yes, release notes should be in the Also, could you please rebase your PR onto main? This mean first of all, updating your When all of the above is complete, please make sure that the title references the corresponding ticket and to adjust the ticket flags in the Trac system so this PR gets added to the "branches needing review" section of the Django Developer Dahsboard. More information in these docs. If you need any help, please ask! Thank you, Natalia. |
Hello @hrushikeshrv, would you have time to keep working on this? Thank you for your efforts so far! |
…s alignment for tablet screen size. Co-authored-by: Sarah Boyce <[email protected]>
Hi @nessita, sorry for the late response! I was a little swamped for the last few weeks, but I will be able to work on this patch now. I'll rebase this PR and address the width and horizontal space concerns asap! |
Thank you! I did not mean to rush you, just knowing that you'll work on this when you can is enough. Good luck! |
Hey @hrushikeshrv, thank you for restarting work on this. Specifically about the "Add" (plus sign) button: I love the new proposed location. Do you think that moving it to that place could be done in isolation/independently of this branch? I'm wondering we could do a separated commit/PRs with that. Of course we should also confirm with the accessibility team (cc @django/accessibility @knyghty) that this "Add" button change is acceptable. Did you happen to check screen readers and tab keyboard navigation? |
@nessita Yes, I think we could do this independently in a separate PR. I haven't checked with screen readers or tab keyboard navigation yet. I can do that and create a ticket if the accessibility team agrees. |
@hrushikeshrv @nessita, I don't see an immediate problem with the new position - I do think it is actually easier to see from a UX perspective and good to have a clear text label as well. However, it's easier to review the accessibility in PR form, so I'd certainly encourage creating one (with a ticket). |
Hi @nessita, I tried to rebase this branch onto main, but it looks like I messed up somehow. I followed the steps you mentioned and the steps in Adam's article, but it looks like I committed every change that has been made since I created my branch. |
No worries, let's see: what command did you run, and how did you resolve conflicts, if there were any? In general, you can undo changes to your git repo by (make a copy of your work before proceeding, just in case). See more, for example, in this stackoverflow link:
With that, your git tree will look like it was at |
696e811
to
b50836a
Compare
@knyghty Sorry for the inactivity. I will be able to work on this, but I might be delayed, since I have just moved, and I'm still in the process of setting up my new house. |
Hi @sarahboyce, I've added some extra margin between labels and inputs and also updated the release notes. If this looks good, I can generate the screenshots. Let me know! |
Thank you for the updates! To me it looks like the margin between the fields and the label still needs some work. Looking at the screenshots generated from the visual regression tests you can see this margin appears to be missing in some cases The "Start date" and "Start time" fields looks great but "Main band" and "Description" look to be quite close to their input - I think the spacing should be consistent and I would like to see similar spacing as to the "Start date" and "Start time" fields Can you also add a screenshot test cases for errors? This will help ease the review (see the screenshots section of running the selenium tests docs for some context) |
Thanks for the review, I'll see what's going wrong. I'll add screenshot test cases for errors as well |
Hi @sarahboyce, is it okay to add the new tests in |
Yes 👍 |
I've added the screenshot test to check for error message positions. I've checked the screenshots locally as well and they seem to be coming out right. Can you confirm @sarahboyce? |
822e0ec
to
6fbdfe1
Compare
Thank you @hrushikeshrv ⭐ I have two questions I see that our multi widgets (see "Date:" and "Time:" below) will have the labels next to the field rather than above A non-blocking thought is "why do the labels end with a colon : ?" If the reason was due to the layout where the label was on the left, then we perhaps could/should remove it. @thibaudcolas is at the sprint I have have asked if he could also do some testing but this is very positive and I think we could generate the screenshots for the docs |
About the date and time fields, those two may need to be wrapped in a Such a change is out of scope for this PR, though. |
FWIW I would also prefer the labels to not have a colon but also keeping the date and time fields roughly the way they are, which might be better with a colon. Which is probably the most annoying thing I could ask for :) But I don't think this should be blocking, I'd be happy with something like this in a follow-up |
@sarahboyce For the docs screenshots, should I use the same models as the current screenshots? If so, where can I find those models? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed this with @nessita and we are happy to merge this before screenshots are updated, screenshots can be updated in a PR prior to the 5.2 release(s)
docs/releases/5.2.txt
Outdated
* In order to improve accessibility: | ||
|
||
* Form fields in the change form are now shown below their respective labels | ||
instead of next to them. | ||
|
||
* Help text in the change form is now shown after the field label and before | ||
the field input. | ||
|
||
* Validation errors in the change form are now shown after the help text and | ||
before the field input. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* In order to improve accessibility: | |
* Form fields in the change form are now shown below their respective labels | |
instead of next to them. | |
* Help text in the change form is now shown after the field label and before | |
the field input. | |
* Validation errors in the change form are now shown after the help text and | |
before the field input. | |
* In order to improve accessibility of the admin change forms: | |
* Form fields are now shown below their respective labels instead of next to | |
them. | |
* Help text is now shown after the field label and before the field input. | |
* Validation errors are now shown after the help text and before the field | |
input. |
I wonder if this should be in the Miscellaneous Backwards incompatible changes in 5.2
section as it isn't so much a feature but rather a change we wish to alert folks of 🤔
I also want an approval from the accessibility team so re-requested a review here 👍 Summary of work needed to land this:
The updates to screenshots is a nice to have in this PR but not blocking and can be addressed later |
Happy to have another look, but will wait until the final widgets are done. |
8d0379c
to
8751360
Compare
Hi @sarahboyce, I ran into a few issues with merge conflicts and rebasing, and I mistakenly erased some history by force pushing. I've tried for a while to try to fix things, but I'm not able to. Is it okay if I close this PR and open a new one from a new branch from current Sorry for the inconvenience 😅 |
Yeah that's fine - do what you need to do 👍 |
Hi @hrushikeshrv, curious if you are still working on this? I would love to continue if not? |
Hi @YounesDjelloul, I'm unfortunately not able to work on this PR at the moment, please do feel free to take over 👍🏻 |
Hi, new here and exploring the codebase, would love to get a little help! I have forked the main branch and tried to run the selenium tests locally! Though some of them are failing, is this normal or am I missing something? |
Hello @YounesDjelloul , if you’re not planning to work on this, would it be okay if I give it a try? |
Yes sir, please go ahead
…On Thu, 31 Jul 2025, 08:24 Antoliny Lee, ***@***.***> wrote:
*Antoliny0919* left a comment (django/django#16975)
<#16975 (comment)>
Hello @YounesDjelloul <https://github.com/YounesDjelloul> , if you’re not
planning to work on this, would it be okay if I give it a try?
—
Reply to this email directly, view it on GitHub
<#16975 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK24MTCBWVA2YZTWO5XORL33LFO33AVCNFSM6AAAAAAZGAUX4WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCMZYGIYDQMJVGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Fixes #34643 by moving admin form labels above the inputs instead of left aligned.
Before -

After -
