Problem/Motivation

The fieldset element can be used to indent a conditional field ("sub-field"), see for example the Twig debug form:

Twig debug
(from #3278493: Make it easier for theme builders to enable Twig debugging and disable render cache)

... so it feels like a sub-element, lower in the hierarchy, even if that was never the intended use.

The question is, what is the best method to indent a form element to the right, to visualize the hierarchy, and signify that this element is at a lower level?

Proposed resolution

Maybe we should consider adding styling to dependent fields and similar fields at a lower levels, and indent them to the right, to signify their hierarchical position?

---

Originally posted as a Claro Compact issue:

Fieldset texts are too far to the left, and need to be moved to the right, to align with the element above.

Steps to reproduce

  1. Visit /admin/config/development/settings
  2. Click "Twig development mode"
  3. See that the header in the opened fieldset ("Twig development mode") is not indented enough, and doesn't align with the elements above

Claro

Fieldset texts are correctly aligned in Claro.

Claro

Claro Compact

Fieldset texts are too far to the left in Claro Compact.

Claro Compact

Remaining tasks

User interface changes

API changes

Data model changes

Comments

ressa created an issue. See original summary.

ressa’s picture

Status: Active » Needs work
ressa’s picture

Issue summary: View changes
ressa’s picture

Issue summary: View changes
djg_tram’s picture

I'm not sure why this would be a problem: the primary purpose is to remove extra space.

You seem to mix two things here. This specific fieldset is, in fact, a dependent fieldset that opens up when the upper checkbox is checked. But this is not a general attribute or use case of fieldsets, this is something specific to this Devel form. If we changed all fieldsets the way you suggest, they would become larger anywhere in the UI, not just in this dependent position.

ressa’s picture

Title: Fieldsets lack indentation » How to best visualize hierarchy between elements in a form?
Project: Claro Compact » Drupal core
Version: 8.x-2.x-dev » 11.1.x-dev
Component: Code » forms system
Category: Bug report » Task
Issue summary: View changes
Status: Needs work » Active
Related issues: +#3510479: How to best visualize hierarchy between elements in a form?

Thanks for a fast reply, I guess the fieldset element as a side effect of the border and text indentation acts a hierarchy signifier. I'll move the issue to Drupal core, to clarify how to best indicate hierarchy between form elements.

ressa’s picture

djg_tram’s picture

I would, frankly, expect Devel to style their form to indent the dependent fieldset in this particular case.

ressa’s picture

I think it would be better to find a universal solution, for cases such as this. Maybe we can add styling to dependent fields and similar "sub-fields", to indent them?

djg_tram’s picture

I can't find anything in the classes that would help us tell apart this case, so it would be a task for the core to add something that we can rely on.

ressa’s picture

Issue summary: View changes

Thanks for investigating, maybe we need a new element, to indicate hierarchy?

djg_tram’s picture

I never looked into the code that generates these form elements, so I really don't know. This is just a shot in the dark, but maybe a class of form-indent-level-N would be beneficial.

quietone’s picture

Version: 11.1.x-dev » 11.x-dev

Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.