Hi, thanks for a great module.
It seems the Visually Hidden setting for label does not have any effect, that is assuming the setting is designed to have the effect inherent in setting the D8 class visually-hidden? Using Drupal 8.3.4 and DS 8.x-3.1

CommentFileSizeAuthor
#7 2893331-7.patch2.27 KBswentel
#6 2893331-6.patch2.27 KBswentel
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PatrickMichael created an issue. See original summary.

jazzper’s picture

The Display Suite field templates don't add a visually-hidden class but a field-label-visually-hidden class. Therefore the CSS that hides the element doesn't get applied.

.visually-hidden {
  position: absolute !important;
  clip: rect(1px, 1px, 1px, 1px);
  overflow: hidden;
  height: 1px;
  width: 1px;
  word-wrap: normal;
}

As an example the part from ds-field.reset.html.twig responsible for this:

{% if not label_hidden %}
  <div class="field-label-{{ element['#label_display']|clean_class }}">
    {{- label }}{% if show_colon %}:{% endif -%}
  </div>
{% endif %}
PieterDC’s picture

Version: 8.x-3.1 » 8.x-3.2
Status: Active » Needs work

Still occurs with Display Suite 8.x-3.2
The bug also occurs with the expert and minimal templates, not only the reset template.

Should we add 'visually-hidden' to 'field-label-visually-hidden' to be backwards compatible?
But then still FieldTemplateTest will probably need some adjustments to keep working.

nhck’s picture

Version: 8.x-3.2 » 8.x-3.x-dev

Should we add 'visually-hidden' to 'field-label-visually-hidden' to be backwards compatible?

Yes please! The issue persists in Drupal 8.8 with Display Suite 8.x-3 - and its really confusing.

Inspired by a related issue #2779743: Hidden/Visually hidden field labels don't work in the basic theme and for a quick fix - I've modified the following lines in ds-field-expert.html.twig

  set title_classes = [
        'field-label-' ~ element['#label_display']|clean_class,
      ]

So they now read:

  set title_classes = [
        'field-label-' ~ element['#label_display']|clean_class,
        (element['#label_display'] == 'visually_hidden' ? 'visually-hidden'),
      ]
swentel’s picture

Hmm, yeah, this is confusing indeed.

We should apply this to expert, minimal and (even) reset, let me see if I can make it work.

swentel’s picture

Status: Needs work » Needs review
FileSize
2.27 KB

This also adds visually hidden to the labels of display suite fields.

swentel’s picture

FileSize
2.27 KB

Patch didn't apply anymore, will commit when green.

  • swentel committed 8e5b9b6 on 8.x-3.x
    Issue #2893331 by swentel: Visually hidden setting for label does not...
swentel’s picture

Status: Needs review » Fixed

committed and pushed, sorry for the delay.

swentel’s picture

Status: Fixed » Closed (fixed)