- Issue created by @fskreuz
- Status changed to Needs review
almost 2 years ago 7:47pm 4 February 2023 The last submitted patch, 2: fences-duplicate_field_and_field_label_classes-3339284-2.patch, failed testing. View results β
- Status changed to Needs work
almost 2 years ago 7:22am 7 February 2023 - π©πͺGermany Anybody Porta Westfalica
Thank you @fskreuz, sorry I wasn't able to reproduce this yet. Which theme are you using?
Could you write a test that shows this issue please? That way we can prove the issue exists, is reproducible and we can prevent it in the future. - πΊπΈUnited States fskreuz
@Anybody The theme I use is based on stable9. I am not able to write tests at the moment.
But to add more info, it's this bit of code in `fences_preprocess_field()` that's causing the issue. Two separate issues (linked, see sidebar), possibly not aware of each other and solving separate issues, merged and duplicated functionality. I hope this helps someone.
// Prevent adding empty classes: if (!empty($fences_config['fences_field_classes'])) { $fences_field_classes = explode(' ', $fences_config['fences_field_classes']); foreach ($fences_field_classes as $class) { // Add classes from setting: $vars['attributes']['class'][] = $class; } } if (!empty($fences_config['fences_label_classes'])) { $fences_field_classes = explode(' ', $fences_config['fences_label_classes']); foreach ($fences_field_classes as $class) { // Add classes from setting: $vars['title_attributes']['class'][] = $class; } } if (!empty($fences_config['fences_field_classes'])) { $vars['attributes']['class'][] = $fences_config['fences_field_classes']; } if (!empty($fences_config['fences_label_classes'])) { $vars['title_attributes']['class'][] = $fences_config['fences_label_classes']; }
- πΊπΈUnited States rlnorthcutt Austin, TX
I can confirm that these duplicate classes are happening, but it seems to be only on the "Field Tag" classes, not all of them.
For example, here is the configuration for my "Body" field:
And here is the output:
Clearing the cache does no good, and resaving the settings does no good. Note that I have another field (taxonomy) with "Field Tag" classes, but those are not duplicated.
- π©πͺGermany Anybody Porta Westfalica
@rlnorthcutt my assumption is, that in this case the classes do not run through Drupal
Attribute
functionality, which should make them unique. Perhaps they are just passed as array, while they are handled correctly in other cases. Perhaps that brings us on the right track.But we have to be 100% sure the specific cases are not caused by a custom / contrib theme, please always compare to a core theme. Which theme(s) did you try?
- π±πΉLithuania vibrasphere
This is still happening with https://www.drupal.org/project/bootstrap5 β but only if there's more than one class separated by space, in my case for simple Link field in a Block type.