[Tracker]
Update Summary: Bug report, AI Suggestions button stays hidden on focus for string_long textarea fields.
Short Description: On-focus un-hide CSS rule in ai_content_suggestions misses .field-widget-action-widget-button for field--type-string-long.
Check-in Date: 04/09/2026
Metadata is used by the AI Tracker. Docs and additional fields here.
[/Tracker]

Problem/Motivation

When the display_on_focus setting is enabled on a field widget action plugin attached to a field--type-string-long field (e.g. a plain textarea field like a teaser text), the AI Suggestions button is hidden by default but stays hidden even when the textarea is focused.

The CSS rule responsible for hiding the button is in modules/ai_content_suggestions/css/field_widget.css:

/* Only show button when fields are focused */
.ai-content-suggestions--on-focus .field-widget-action-widget-button {
  display: none;
}

The corresponding rules that un-hide the button on focus cover field--type-string, field--type-text-long, and both .field-widget-action-widget-button and the legacy .ai-content-suggestions.button classes — except for field--type-string-long, where only the .ai-content-suggestions.button variant is listed:

.field--type-string.ai-content-suggestions--on-focus:has(input:focus) .field-widget-action-widget-button,
.field--type-text-long.ai-content-suggestions--on-focus:has(.ck-focused) .field-widget-action-widget-button,
.field--type-string.ai-content-suggestions--on-focus:has(input:focus) .ai-content-suggestions.button,
.field--type-string-long.ai-content-suggestions--on-focus:has(textarea:focus) .ai-content-suggestions.button,
.field--type-text-long.ai-content-suggestions--on-focus:has(.ck-focused) .ai-content-suggestions.button {
  display: block;
}

The actual button rendered by the field_widget_actions module uses the class field-widget-action-widget-button, not ai-content-suggestions.button. As a result, on a plain-textarea field (field--type-string-long) with display_on_focus: true, the button is hidden permanently — the un-hide rule never matches.

Verified against 1.3.1, 1.3.2, 1.3.x-dev and 1.4.x-dev — the field_widget.css file is byte-identical across all four, so the bug is present in every currently supported release and dev branch.

Steps to reproduce (required for bugs, but not feature requests)

  1. Install ai 1.3.1 (or 1.4.x-dev) with the ai_content_suggestions and field_widget_actions sub-modules enabled.
  2. On a content type, add a plain textarea field (field type string_long, widget string_textarea) — for example, a "Teaser text" field.
  3. On the node edit form display, enable a prompt_content_suggestion field widget action on that field with display_on_focus: true.
  4. Open the node edit form and focus the textarea.

Expected: The AI Suggestions button becomes visible while the textarea is focused, then hides again on blur (matching the behavior of field--type-string fields such as the node title).

Actual: The button remains hidden regardless of focus state.

Proposed resolution

Add .field-widget-action-widget-button to the un-hide rule for field--type-string-long in modules/ai_content_suggestions/css/field_widget.css:

.field--type-string.ai-content-suggestions--on-focus:has(input:focus) .field-widget-action-widget-button,
.field--type-string-long.ai-content-suggestions--on-focus:has(textarea:focus) .field-widget-action-widget-button,
.field--type-text-long.ai-content-suggestions--on-focus:has(.ck-focused) .field-widget-action-widget-button,
.field--type-string.ai-content-suggestions--on-focus:has(input:focus) .ai-content-suggestions.button,
.field--type-string-long.ai-content-suggestions--on-focus:has(textarea:focus) .ai-content-suggestions.button,
.field--type-text-long.ai-content-suggestions--on-focus:has(.ck-focused) .ai-content-suggestions.button {
  display: block;
}

Remaining tasks

  1. Confirm whether the legacy .ai-content-suggestions.button selectors are still needed or whether all current code paths render .field-widget-action-widget-button. If the legacy class is dead, the rule can be simplified.
  2. Verify on a string_long field that the button toggles correctly on focus/blur.

User interface changes

None once fixed: the button becomes visible on focus as intended. Currently, the UI silently omits the button on string_long fields configured for display_on_focus.

API changes

None.

Duplicate check

✅ Duplicate check — no existing issue found. Searched the drupal/ai open issue queue with no relevant results.

Related but not duplicate:
- #3571915 Allow Field Widget Actions to target a specific automator — feature request, different scope
- #3567027 Field Widget Button labels are not translatable via UI — translation, not visibility

AI usage (if applicable)

[x] AI Assisted Issue
This issue was generated with AI assistance, but was reviewed and refined by the creator.

[ ] AI Assisted Code
This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.

[ ] AI Generated Code
This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.

[ ] Vibe Coded
This code was generated by an AI and has only been functionally tested.

Comments

jjchinquist created an issue. See original summary.

jjchinquist’s picture

Priority: Normal » Minor
Issue summary: View changes

Changing prio to minor. It affects our project, but I assume it will not affect many people. I will try to get a patch created to fix the issue on our project and hopefully get it working for everyone.

jjchinquist’s picture

Issue summary: View changes