#34383: Layout error in Admin when using help_text
-------------------------------------+-------------------------------------
     Reporter:  Antonio Candido      |                    Owner:  nobody
  Nazareth junior                    |
         Type:  Bug                  |                   Status:  new
    Component:  Template system      |                  Version:  4.2
     Severity:  Release blocker      |               Resolution:
     Keywords:  help_text            |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

 I tried to fix this, it's much better (but not perfect, you can see minor
 issues on the "Change user" view) with the following diff:
 {{{#!diff
 diff --git a/django/contrib/admin/static/admin/css/forms.css
 b/django/contrib/admin/static/admin/css/forms.css
 index 3cd87ef476..e73831a83f 100644
 --- a/django/contrib/admin/static/admin/css/forms.css
 +++ b/django/contrib/admin/static/admin/css/forms.css
 @@ -72,7 +72,7 @@ form ul.inline li {
  /* ALIGNED FIELDSETS */

  .aligned label {
 -    display: block;
 +    display: inline-block;
      padding: 4px 10px 0 0;
      width: 160px;
      word-wrap: break-word;
 @@ -114,7 +114,7 @@ form ul.inline li {
  }

  form .aligned ul {
 -    margin-left: 160px;
 +    margin-left: 166px;
      padding-left: 10px;
  }

 @@ -127,7 +127,7 @@ form .aligned div.radiolist {
  form .aligned p.help,
  form .aligned div.help {
      margin-top: 0;
 -    margin-left: 160px;
 +    margin-left: 166px;
      padding-left: 10px;
  }

 @@ -191,7 +191,6 @@ form .aligned table p {
  }

  fieldset .fieldBox {
 -    float: left;
      margin-right: 20px;
  }

 diff --git a/django/contrib/admin/static/admin/css/widgets.css
 b/django/contrib/admin/static/admin/css/widgets.css
 index 572dc0a500..c81bcf654d 100644
 --- a/django/contrib/admin/static/admin/css/widgets.css
 +++ b/django/contrib/admin/static/admin/css/widgets.css
 @@ -578,7 +578,6 @@ ul.timelist, .timelist li {

  /* RELATED WIDGET WRAPPER */
  .related-widget-wrapper {
 -    float: left;       /* display properly in form rows with multiple
 fields */
      overflow: hidden;  /* clear floated contents */
  }

 diff --git a/django/contrib/admin/templates/admin/includes/fieldset.html
 b/django/contrib/admin/templates/admin/includes/fieldset.html
 index 5953a5ad3d..0d398d1de1 100644
 --- a/django/contrib/admin/templates/admin/includes/fieldset.html
 +++ b/django/contrib/admin/templates/admin/includes/fieldset.html
 @@ -6,26 +6,30 @@
      {% for line in fieldset %}
          <div class="form-row{% if line.fields|length == 1 and line.errors
 %} errors{% endif %}{% if not line.has_visible_field %} hidden{% endif
 %}{% for field in line %}{% if field.field.name %} field-{{
 field.field.name }}{% endif %}{% endfor %}">
              {% if line.fields|length == 1 %}{{ line.errors }}{% endif %}
 -            {% for field in line %}
 -                <div{% if not line.fields|length == 1 %}
 class="fieldBox{% if field.field.name %} field-{{ field.field.name }}{%
 endif %}{% if not field.is_readonly and field.errors %} errors{% endif
 %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif
 field.is_checkbox %} class="checkbox-row"{% endif %}>
 -                    {% if not line.fields|length == 1 and not
 field.is_readonly %}{{ field.errors }}{% endif %}
 -                    {% if field.is_checkbox %}
 -                        {{ field.field }}{{ field.label_tag }}
 -                    {% else %}
 -                        {{ field.label_tag }}
 -                        {% if field.is_readonly %}
 -                            <div class="readonly">{{ field.contents
 }}</div>
 -                        {% else %}
 -                            {{ field.field }}
 -                        {% endif %}
 -                    {% 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>{{ field.field.help_text|safe }}</div>
 -                    </div>
 -                {% endif %}
 -            {% endfor %}
 +            <div>
 +              {% for field in line %}
 +                <div>
 +                  <div{% if not line.fields|length == 1 %}
 class="fieldBox{% if field.field.name %} field-{{ field.field.name }}{%
 endif %}{% if not field.is_readonly and field.errors %} errors{% endif
 %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif
 field.is_checkbox %} class="checkbox-row"{% endif %}>
 +                      {% if not line.fields|length == 1 and not
 field.is_readonly %}{{ field.errors }}{% endif %}
 +                      {% if field.is_checkbox %}
 +                          {{ field.field }}{{ field.label_tag }}
 +                      {% else %}
 +                          {{ field.label_tag }}
 +                          {% if field.is_readonly %}
 +                              <div class="readonly">{{ field.contents
 }}</div>
 +                          {% else %}
 +                              {{ field.field }}
 +                          {% endif %}
 +                      {% 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>{{ field.field.help_text|safe }}</div>
 +                      </div>
 +                  {% endif %}
 +                  </div>
 +              {% endfor %}
 +            </div>
          </div>
      {% endfor %}
  </fieldset>
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34383#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701870983f9db-0d1d0893-7aa9-409d-bc45-0e9b393ccd17-000000%40eu-central-1.amazonses.com.

Reply via email to