-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Fixed #34643 -- Moved admin form label to a more accessible place. #19713
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
ebb0cfd
to
afe5bd6
Compare
029beaa
to
69cf786
Compare
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.
- Note that when the PR is close to being merged, we should update the admin doc images
- Please make @hrushikeshrv a co-author of the commit
- On the previous PR I mentioned the Date/Time widget having the date and time label next to the input, this is the case in this PR (#16975 (comment)). However, I imagine when #19678 is merged, the layout would change (as currently Date/Time are in
<p>
tags rather than labels). We need to agree what is wanted and then make sure this stays consistent after changes in other PRs
@@ -4,7 +4,7 @@ | |||
|
|||
.form-row { | |||
overflow: hidden; | |||
padding: 10px; | |||
padding: 10px 0; |
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.
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.
That’s a good point. Thank you.
tests/admin_views/tests.py
Outdated
self.live_server_url + reverse("admin:admin_views_language_add") | ||
) | ||
save = self.selenium.find_element(By.CSS_SELECTOR, "div.submit-row input") | ||
save.click() |
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.
save.click() | |
with self.wait_page_loaded(): | |
save.click() |
Possibly
Yes, I’m aware of this.
Yes, I’ll add it :)
Yes, is the layout you had in mind when you commented on the previous PR something like this? ![]() It’s likely that once #19678 is merged, the layout will change to the form shown above. Personally, I feel that for consistency, the date and time labels should be structured like the above. For reference, when adjusting the layout of the date and time fields, I will add a label tag and apply some minor styling. |
@@ -1,4 +1,4 @@ | |||
<p class="datetime"> |
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.
Shouldn't we change this tag to a div
someday?
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 agree that a div probably makes more sense and we may not want the <br>
either
But this can come later
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’ll create a separate issue for this.
django/contrib/admin/helpers.py
Outdated
label_suffix="" if self.is_checkbox else None, | ||
label_suffix="", |
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.
Having thought about this more, I think we should keep the colon as it's the default for Django forms
If we want to change this, I think we should change the default for Django forms to not have a label suffix
Also note that AdminSplitDateTime
hardcodes the Date and Time label with a colon and we would need to update this if we were to remove the colons
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 agree. I also think it’s better to keep the colon.
At first, I thought it might be better to remove it, but having the colon actually feels more intuitive and unambiguous.
@@ -1,4 +1,4 @@ | |||
<p class="datetime"> |
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 agree that a div probably makes more sense and we may not want the <br>
either
But this can come later
fieldset .fieldBox { | ||
margin-right: 20px; | ||
} | ||
|
||
/* WIDE FIELDSETS */ |
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.
So the "wide" class is documented as:
Fieldsets with the
wide
style will be given extra horizontal space in the admin interface.
https://docs.djangoproject.com/en/5.2/ref/contrib/admin/#:~:text=wide.
I am struggling to see the effects of this. I wonder if this is something that "broke" recently (so perhaps it's easier to see in 5.1 etc.)
Given the new label styling, this "wide" class may no longer make sense (see that this is already 90% deleted).
If we are removing this class, we should update the docs and add a release note within the breaking changes
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’ll check this. If it’s possible to remove the wide class completely, I think it would be best to do so.
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 found that when the wide class was added, the label widths increased slightly. Other CSS rules also relied on the wider labels.
(It seems that there wasn't much difference even in the previous versions.)
Now that labels are positioned above the fields, these CSS rules can be safely removed, and the wide class no longer seems to serve any purpose.
(For reference, in the image above, the text field overlaps the label because I temporarily removed some CSS to check the layout with the wide class applied.)
76b9294
to
ab10664
Compare
Please add it to the accessibility improvement project board 🙏 |
f409028
to
bce9df8
Compare
Co-authored-by: Hrushikesh Vaidya <hrushikeshrv@gmail.com>
bce9df8
to
083b7f7
Compare
Trac ticket number
ticket-34643
Branch description
Continue PR...
Thank you for working on this for such a long time @hrushikeshrv ❤️
I have modified the internal structure of the admin form fields.(more accessible) 🙌🙌🙌
Checklist
main
branch.