Problem/Motivation

  • Currently assumes Vertical and Horizontal Tabs markup and containes theme-specific logic for those layouts.
  • USWDS Base and potentially other themes render Field Group tabs as accordions with different markup (no <details>, custom classes, etc.), which caused Field Group Complete to fail to attach any behavior at all.
  • The previous approach also introduced a more complex PHP/JS contract (pane → tab mapping, hooks, and handler concepts) that proved unnecessary once we discovered a robust, universal selector.

Proposed resolution

Refactor Field Group Complete’s JS and form alter to:

  • Use a universal pane selector that targets the Field Group tabs container in a theme-agnostic way.
  • Use a single, generalized trigger selector for tab labels/buttons:
    const DEFAULT_TRIGGER_SELECTOR =
      '.field-group-tabs-wrapper a[href^="#edit-group-"], ' +
      '.field-group-tabs-wrapper button[aria-controls^="edit-group-"]';
    
  • Keep the logic for mapping “pane → trigger” fully client-side and markup-driven, without theme-specific PHP hooks.

Split the JavaScript into:

  • js/field_group_complete.core.js: core logic (required detection, completeness computation, badge creation, class toggling, etc.).
  • js/field_group_complete.js: the Drupal behavior (initialization, selector discovery, and calling into the core functions).

Retain vertical/horizontal tabs support by:

  • Continuing to look up triggers inside the same .field-group-tabs-wrapper container.
  • Preserving compatibility with Vertical Tabs’ .vertical-tabs__menu-link-content as an optional inner label wrapper when present.

Remove the experimental pane ↔ tab mapping hooks and handler APIs introduced earlier, since they are no longer necessary with the universal selector approach.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jcandan created an issue. See original summary.

  • jcandan committed a0f68bde on 1.x
    feat: #3563510 Refactor for broader theme support and simpler selector-...
jcandan’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.