[Django] #35755: Regression: Help text for hidden fields shows

6 views
Skip to first unread message

Django

unread,
Sep 11, 2024, 11:42:56 PM9/11/24
to django-...@googlegroups.com
#35755: Regression: Help text for hidden fields shows
--------------------------------+-----------------------------------------
Reporter: Richard Laager | Type: Bug
Status: new | Component: contrib.admin
Version: 4.2 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+-----------------------------------------
This is present in 4.2 through git main.

If a field is hidden, its help_text shows.

This regressed in commit 96a598356a9ea8c2c05b22cadc12e256a3b295fd:
https://github.com/django/django/commit/96a598356a9ea8c2c05b22cadc12e256a3b295fd

from PR 16161:
https://github.com/django/django/pull/16161

This happened because the <div class="help"> is now after, as opposed to
inside, the <div> that gets class "hidden".

There are two possible fixes:

A) Do not output the help div at all:

{{{
--- a/django/contrib/admin/templates/admin/includes/fieldset.html
+++ b/django/contrib/admin/templates/admin/includes/fieldset.html
@@ -26,7 +26,7 @@
{% endif %}
{% endif %}
</div>
- {% if field.field.help_text %}
+ {% if field.field.help_text and not
field.field.is_hidden %}
<div class="help"{% if field.field.id_for_label
%} id="{{ field.field.id_for_label }}_helptext"{% endif %}>
<div>{{ field.field.help_text|safe }}</div>
</div>
}}}

B) Set "hidden" on the help div:
{{{
--- a/django/contrib/admin/templates/admin/includes/fieldset.html
+++ b/django/contrib/admin/templates/admin/includes/fieldset.html
@@ -27,7 +27,7 @@
{% endif %}
</div>
{% if field.field.help_text %}
- <div class="help"{% if field.field.id_for_label
%} id="{{ field.field.id_for_label }}_helptext"{% endif %}>
+ <div class="help{% if field.field.is_hidden %}
hidden{% endif %}"{% if field.field.id_for_label %} id="{{
field.field.id_for_label }}_helptext"{% endif %}>
<div>{{ field.field.help_text|safe }}</div>
</div>
{% endif %}
}}}

Either fix works. I'm just not sure stylistically which one you want.
--
Ticket URL: <https://code.djangoproject.com/ticket/35755>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 11, 2024, 11:45:03 PM9/11/24
to django-...@googlegroups.com
#35755: Regression: Help text for hidden fields shows
--------------------------------+--------------------------------------
Reporter: Richard Laager | Owner: (none)
Type: Bug | Status: new
Component: contrib.admin | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Richard Laager):

* easy: 0 => 1
* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35755#comment:1>
Reply all
Reply to author
Forward
0 new messages