Format settings entirely disappear when clicking "Add the classes to the A tag"

Created on 18 August 2022, over 2 years ago
Updated 4 June 2023, over 1 year ago

Problem/Motivation

I'm getting some very unexpected behavior when trying to configure a "Link icon, based on title" field. Every time I try to click the "Add the classes to the A tag" checkbox, the entire format settings sub-form disappear. The only clue as to what might have gone wrong is that the dblog has a new entry reading Notice: Undefined index: #type in Drupal\Core\Form\FormHelper::processStates() (line 211 of /code/web/core/lib/Drupal/Core/Form/FormHelper.php). The browse console is silent (tested in FF and Chrome on Mac).

Steps to reproduce

Attached is a short video showing steps 3-7.

1. With this module enabled, add a link field to a content type.
2. Go to the "Manage display" page.
3. Ensure the field is enabled, and set its format to "Link icon, based on title"
4. Click the gear icon at right to reveal the set of options for this formatter.
5. Click the "Add the classes to the A tag" checkbox and watch the entire set of options disappear.

Exacerbated edition:
6. While the options are still disappeared, click "Save" for the "Manage display" page as a whole.
7. Click the gear again, only to find that now none of the options will appear.

(Workaround to get back to the state where at least the gear works to show the options again is to (a) refresh the page, (b) select a different format for the field, (c) "Save" the page again, (d) then change back to the linkicon-provided formatter.)

Proposed resolution

[The following isn't a resolution, just what I was able to find when trying to debug]

The dblog notice led me to 🐛 Notice: Undefined index: #type in Drupal\Core\Form\FormHelper::processStates() Needs work , which is ostensibly be about #markup elements generating the notice (and seemingly in most cases as just background noise), and the latest patch there just suppresses the warning without changing the linkicon breakage. The checkbox in question is clearly not #type of #markup, but some comments in that issue like #68 led me to wonder whether other #markup elements in this module might be affecting things, so I tried out patches that removed lines 51-54 ($elements['opening'] stuff) and 298-301 ($icon_previews[] stuff) from LinkIconFormatterTrait.php, but still no luck.

It could I guess be that the "Manage display" page has other #markup coming from core, which might also be affecting this problem. I also wondered if it wasn't more "simply" that the various #states conditions related to linkicon_link in LinkIconFormatterTrait.php might be inadvertently causing more things to become non-visible than expected, but (a) trying to follow all the conditions/logic was making my head hurt (especially being unfamiliar with this module before today), and (b) when I inspect source when clicking the offending checkbox, it seems display:none is getting applied all the way up at .field-plugin-settings-edit-form (which makes me think maybe there is a core problem at play after all?).

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

1.7

Component

Code

Created by

🇺🇸United States maxstarkenburg Washington, DC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024