Skip to content

docking: tabs can carry a × that closes the panel, shown on hover for inactive tabs - #428

Closed
pravdomil wants to merge 1 commit into
storytold:mainfrom
pravdomil:craft-ui/tab-close-button
Closed

pravdomil wants to merge 1 commit into
storytold:mainfrom
pravdomil:craft-ui/tab-close-button

Conversation

@pravdomil

@pravdomil pravdomil commented Oct 29, 2026 •

Copy link
Copy Markdown

What

Panel tabs in craft_ui::docking had no close button; a tab closed only with a middle click or from its menu. This adds an opt-in × after a tab's label:

  • DockContent::tab_close(panel) (default false): the host picks the panels whose tab has a ×. Only closable panels get one, so a locked layout shows none.
  • Shown on the active tab always, on an inactive tab while the pointer is over it, so an inactive tab closes without being activated first.
  • The tab keeps the ×'s room either way (16 pt), so it keeps its width when hovered or activated.
  • Hit::TabClose(P) names the button for automation and tests.
  • docs/ui-docking.md describes it.

Motivation: EffectCraft's viewer tabs (Composition, Layer, Footage) close from their tab, as in After Effects. EffectCraft's own tab strip had this before it moved to craft_ui::docking (storytold/effectcraft#2432); see storytold/effectcraft#822.

Testing

  • New test tab_close_shows_on_the_active_tab_and_on_a_hovered_inactive_tab (group_tests.rs): the × shows on the active tab, on a hovered inactive tab only, never on a panel the host gives none; tabs keep their width; a click on an inactive tab's × closes only that panel; a locked layout shows none.
  • cargo fmt --check, cargo clippy -p craft-ui --all-features --all-targets -- -D warnings and cargo test -p craft-ui --all-features pass.
  • Not checked visually in an app.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Applications can enable close controls for closable tabs. The × appears on the active tab and on inactive tabs when hovered; reserved space keeps tab widths consistent.
    • Selecting a tab’s close control closes it without changing the active panel. Close controls are hidden in locked layouts.
  • Documentation
    • Updated docking guidance to explain when tab close controls appear and how they behave.

… inactive tabs

A host turns it on per panel with `DockContent::tab_close`; only closable
panels get one. The active tab always shows its ×, an inactive tab while the
pointer is over it, so an inactive tab closes without being activated first.
The tab keeps the ×'s room either way and so keeps its width. `Hit::TabClose`
names the button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

Docking tabs now support opt-in close controls. Eligible controls appear on active tabs or hovered inactive tabs, reserve space consistently, and close the selected panel when clicked.

Changes: Docking tab close controls

Layer / File(s) Summary
Close-control contract
crates/ui/src/docking/surface.rs, crates/ui/src/docking/hits.rs
DockContent::tab_close defaults to false. Hit::TabClose identifies the control and is registered with a close-specific widget ID.
Close-control rendering and interaction
crates/ui/src/docking/render/group.rs, crates/ui/src/docking/group_tests.rs, docs/ui-docking.md
Tab rendering reserves close-control width for eligible panels and shows the control on active tabs or hovered inactive tabs. Clicking it emits Action::Close. Tests cover visibility, width, closing an inactive panel, and locked layouts; documentation describes the behavior.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant DockContent
  participant TabRenderer
  participant User
  participant DockingAction
  DockContent->>TabRenderer: tab_close(panel) enables close control
  TabRenderer->>User: Draw control on eligible tab
  User->>TabRenderer: Click close control
  TabRenderer->>DockingAction: Emit Action::Close
Loading

Possibly related issues

Suggested reviewers: aiongg

Merge Risk: Moderate · up to 79360

Hosts using customized docking cannot show the new tab-close controls for opted-in panels. Forward the opt-in before merging.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@pravdomil pravdomil closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant