Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Antoliny0919
Copy link
Contributor

@Antoliny0919 Antoliny0919 commented Aug 8, 2025

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) 🙌🙌🙌

new_field_example

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

@Antoliny0919 Antoliny0919 force-pushed the moved_admin_form_label branch 2 times, most recently from ebb0cfd to afe5bd6 Compare August 8, 2025 02:35
@Antoliny0919
Copy link
Contributor Author

Antoliny0919 commented Aug 8, 2025

Changed

Before

before_34643(1)

After

after_34643

@Antoliny0919 Antoliny0919 force-pushed the moved_admin_form_label branch 5 times, most recently from 029beaa to 69cf786 Compare August 8, 2025 12:35
@sarahboyce sarahboyce added selenium Apply to have Selenium tests run on a PR screenshots 🖼️ labels Aug 8, 2025
Copy link
Contributor

@sarahboyce sarahboyce left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
padding: 10px 0;
padding: 10px;

I believe we should revert this, otherwise the inline alignment in particular looks very strange
Screenshot from 2025-08-08 15-41-45

Copy link
Contributor Author

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.

self.live_server_url + reverse("admin:admin_views_language_add")
)
save = self.selenium.find_element(By.CSS_SELECTOR, "div.submit-row input")
save.click()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
save.click()
with self.wait_page_loaded():
save.click()

Possibly

@Antoliny0919
Copy link
Contributor Author

Antoliny0919 commented Aug 8, 2025

  • Note that when the PR is close to being merged, we should update the admin doc images

Yes, I’m aware of this.
However, I’d like to do this at the very end.
If it’s okay, could you give me a heads up right before this work gets approved?

Yes, I’ll add it :)

  • 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 Fixed #35892 -- Supported Widget.use_fieldset in admin forms.  #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

Yes, is the layout you had in mind when you commented on the previous PR something like this?

before_pr_example

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.
Also, while working on this, I felt that I wanted to remove the colon.
Having a colon definitely makes the field label clearer, but if the label is still clearly perceived without the colon, I would prefer to remove it.
For now, I will remove the colon in this change and also adjust the structure of the date and time fields.

For reference, when adjusting the layout of the date and time fields, I will add a label tag and apply some minor styling.
I’m not sure if this change is directly related to this PR, but regardless, I believe it is the right direction from multiple aspects (accessibility, layout).

@Antoliny0919
Copy link
Contributor Author

Antoliny0919 commented Aug 9, 2025

Colon (O)

Screenshot 2025-08-09 at 11 19 08 AM Screenshot 2025-08-09 at 11 19 22 AM

Colon (X)

Screenshot 2025-08-09 at 11 19 51 AM Screenshot 2025-08-09 at 11 20 21 AM

@@ -1,4 +1,4 @@
<p class="datetime">
Copy link
Contributor Author

@Antoliny0919 Antoliny0919 Aug 9, 2025

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?

Copy link
Contributor

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

Copy link
Contributor Author

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.

label_suffix="" if self.is_checkbox else None,
label_suffix="",
Copy link
Contributor

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

Copy link
Contributor Author

@Antoliny0919 Antoliny0919 Aug 14, 2025

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">
Copy link
Contributor

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 */
Copy link
Contributor

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

Copy link
Contributor Author

@Antoliny0919 Antoliny0919 Aug 14, 2025

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.

Copy link
Contributor Author

@Antoliny0919 Antoliny0919 Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wide_example

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.)

@Antoliny0919
Copy link
Contributor Author

Please add it to the accessibility improvement project board 🙏

Co-authored-by: Hrushikesh Vaidya <hrushikeshrv@gmail.com>
@Antoliny0919 Antoliny0919 force-pushed the moved_admin_form_label branch from bce9df8 to 083b7f7 Compare August 23, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
screenshots 🖼️ selenium Apply to have Selenium tests run on a PR
Projects
Development

Successfully merging this pull request may close these issues.

2 participants