Skip to content

[MOOSE-360] FE: Refactor Horizontal Tabs Block#333

Merged
GeoffDusome merged 4 commits intomainfrom
feature/MOOSE-360/refactor-horizontal-tabs-block
Mar 30, 2026
Merged

[MOOSE-360] FE: Refactor Horizontal Tabs Block#333
GeoffDusome merged 4 commits intomainfrom
feature/MOOSE-360/refactor-horizontal-tabs-block

Conversation

@GeoffDusome
Copy link
Copy Markdown
Contributor

@GeoffDusome GeoffDusome commented Mar 17, 2026

What does this do/fix?

Reordering

  • Drag-and-drop: Tabs can be reordered by dragging the handle (using @dnd-kit/core and @dnd-kit/sortable with horizontalListSortingStrategy).
  • Persistence: Reordering is persisted on save by using moveBlockToPosition so the block tree (and saved content) stays in the correct order.
  • Immediate UI update: The tab bar is derived from innerBlocks via useSelect and useMemo instead of syncing into attributes in useEffect, so the list re-renders as soon as the block order changes.

Dynamic block refactor

  • PHP render: The block is rendered on the front-end via render.php and no longer uses save.js for the outer markup.
  • Save: Only inner blocks are saved (<InnerBlocks.Content /> in the block’s save), so tab order comes from the saved block order.
  • Controller: Horizontal_Tabs_Block_Controller in plugins/core/src/Components/Blocks/ builds the tab list from $block->parsed_block['innerBlocks'] so order is a single source of truth and survives save/reload.

Active tab behavior

  • Front-end: The first tab is always the active one; the “current active tab” attribute is no longer used in PHP.
  • Editor: The editor always opens with the first tab active (using a ref so this runs once per mount and isn’t overwritten when reordering).

Editor UX

  • Activate tab when editing label: Focusing the tab label (e.g. clicking to edit) also activates that tab via an onFocus handler that calls onSelectTab(tab.id).

Accessibility

  • Tab row: The clickable tab row has role="button", tabIndex={0}, aria-pressed, and an onKeyDown handler so Enter/Space activate the tab; key handling is skipped when focus is inside the label’s contenteditable.

Theming

  • Drag handle: The drag handle uses the same Button component and variant="link" as the delete button so it shares theme styles.
  • Editor colors: Drag handle and delete button both use --horizontal-tabs-editor-delete-color and --horizontal-tabs-editor-delete-hover-color in editor.pcss so they stay visible in light/dark (and brand) themes.

Files changed

  • Theme: horizontal-tabs/edit.js, horizontal-tabs/render.php, horizontal-tabs/editor.pcss, horizontal-tabs/block.json, horizontal-tabs/index.js; removed horizontal-tabs/save.js.
  • Plugin: Added Horizontal_Tabs_Block_Controller.php; no changes to the horizontal-tab child block.

QA

Links to relevant issues

Screenshots/video:

Pull request checklist

  • I've added a changelog entry for these changes.
  • I've linked to a relevant Jira issue.
  • I've captured a screenshot or screencast of the changes and linked it above.

Copy link
Copy Markdown
Collaborator

@dpellenwood dpellenwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 This is an impressive improvement to the tabs block, Geoff. Nice work!

@GeoffDusome GeoffDusome added the In QA Waiting on QA label Mar 27, 2026
@GeoffDusome GeoffDusome merged commit f41a698 into main Mar 30, 2026
7 checks passed
@GeoffDusome GeoffDusome deleted the feature/MOOSE-360/refactor-horizontal-tabs-block branch March 30, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

In QA Waiting on QA Launch Environment Deploys to dokku

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants