Skip to content

resizable: Expose whether a handle is being dragged - #4039

Merged
huacnlee merged 2 commits into
longbridge:mainfrom
costajohnt:feat/resizable-is-resizing
Nov 19, 2026
Merged

huacnlee merged 2 commits into
longbridge:mainfrom
costajohnt:feat/resizable-is-resizing

Conversation

@costajohnt

Copy link
Copy Markdown
Contributor

Closes #4037

Description

Adds ResizableState::is_resizing(), so render code can tell a handle is being dragged (ResizablePanelEvent::Resized only fires once the drag ends). resizing_panel_ix already tracks this; the getter only exposes it. This touches gpui-base because the issue asks for exactly this Base-layer accessor.

One thing the getter makes visible: resizing_panel_ix is only cleared on a mouse up the group paints and in resize_panel, so it stays set after cx.stop_active_drag cancels a drag or after clear() mid-drag, until the next mouse up. That's existing behaviour and I left it alone here; happy to follow up if you'd like clear() or a cancel path to reset it.

Public API

gpui-base

  • ResizableState::is_resizing(&self) -> bool: whether one of the group's resize handles is being dragged right now.

How to Test

  • The existing dragging_the_handle_resizes_and_emits_once test now also checks is_resizing() before the drag, during it and after the release. It fails if the getter returns a constant true or false.
  • cargo test -p gpui-base (1768 lib tests plus the other targets), cargo clippy -p gpui-base --all-targets -- -D warnings, rustfmt --check on the file.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

The method and test in this PR were written with AI assistance (Claude).

Add `ResizableState::is_resizing`, which reports whether one of the
group's resize handles is being dragged. `ResizablePanelEvent::Resized`
only arrives once a drag ends, so render code had no way to tell that a
drag is in progress.

Closes #4037
@huacnlee

Copy link
Copy Markdown
Member

💡 Small read-only getter; looks right to me, but it adds public API, so a maintainer will decide.

Reviewed head 0a20eab.

API review

  • Need: ResizablePanelEvent::Resized only fires after the drag ends. Because resizing_panel_ix is private, render code can't tell that a drag is in progress, which is the case in ResizableState: expose whether a handle is being dragged (is_resizing) #4037 (widening size_range only while dragging). A getter is the smallest way to cover this.
  • Naming: is_resizing() matches the existing DockPlacement::is_resizing() (crates/base/src/dock/dock_placement.rs). It returns a bool without exposing the panel index. Looks good.
  • Suggestion: As the PR description notes, the flag survives clear() and cx.stop_active_drag mid-drag, so is_resizing() can report a stale true until the next mouse up. With the flag now public, please reset it in clear() in this PR rather than in a follow-up. Also, on_drag sets the flag without cx.notify(). It would be worth one line in the doc comment that the value is meant to be read during the drag's re-renders.

Ran

  • cargo test -p gpui-base --all-features resizable: 22 passed.

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@huacnlee

Copy link
Copy Markdown
Member

✅ API accepted: ResizableState::is_resizing() is a small, read-only getter consistent with DockPlacement::is_resizing(), and the existing resized event cannot report an in-progress drag.

Remaining before merge: please reset the flag in clear() / when a drag is cancelled, so it cannot stay true after the drag ends. Reviewed head 0a20eab.

🤖 Noop (reviewer) · AI agent acting for @huacnlee

clear() now resets the flag, and a drag stopped with stop_active_drag is
ended on the next frame, as a mouse up would, so is_resizing() cannot
stay true after the drag ends.
@costajohnt

Copy link
Copy Markdown
Contributor Author

Thanks! Updated in ed31dc8:

  • clear() now resets the flag.
  • A drag cancelled with cx.stop_active_drag gets no mouse up, so the group now checks cx.has_active_drag() when it paints. If the flag is still set but the drag is gone, it ends the drag right after that frame, the same way a mouse up does (done_resizing plus on_resize, and it notifies). The mouse move handler also ignores moves once the drag is gone, so queued moves after a cancel don't keep resizing.
  • Added the doc line saying the value is meant to be read in the re-renders during the drag, since starting a drag doesn't notify.

New tests: clearing_mid_drag_stops_resizing and stopping_the_drag_ends_resizing. Both fail without the fix. cargo test -p gpui-base resizable passes (23, or 24 with --all-features), and clippy -D warnings and cargo fmt --check are clean.

@huacnlee

Copy link
Copy Markdown
Member

✅ LGTM: the requested reset is in; is_resizing() now clears on clear() and on a cancelled drag.

Reviewed head ed31dc8. clear() resets resizing_panel_ix, and a drag ended via stop_active_drag is finalized on the next frame like a mouse up. Both new tests cover it. Ran cargo test -p gpui-component --lib resizable: 23 passed. The public API (is_resizing) was already accepted earlier; no further API change.

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@huacnlee
huacnlee merged commit edf2a57 into longbridge:main Nov 19, 2026
18 of 19 checks passed
linruohan pushed a commit to linruohan/gpui-kit that referenced this pull request Nov 20, 2026
Closes longbridge#4037

## Description

Adds `ResizableState::is_resizing()`, so render code can tell a handle
is being dragged (`ResizablePanelEvent::Resized` only fires once the
drag ends). `resizing_panel_ix` already tracks this; the getter only
exposes it. This touches `gpui-base` because the issue asks for exactly
this Base-layer accessor.

One thing the getter makes visible: `resizing_panel_ix` is only cleared
on a mouse up the group paints and in `resize_panel`, so it stays set
after `cx.stop_active_drag` cancels a drag or after `clear()` mid-drag,
until the next mouse up. That's existing behaviour and I left it alone
here; happy to follow up if you'd like `clear()` or a cancel path to
reset it.

## Public API

### gpui-base

- `ResizableState::is_resizing(&self) -> bool`: whether one of the
group's resize handles is being dragged right now.

## How to Test

- The existing `dragging_the_handle_resizes_and_emits_once` test now
also checks `is_resizing()` before the drag, during it and after the
release. It fails if the getter returns a constant `true` or `false`.
- `cargo test -p gpui-base` (1768 lib tests plus the other targets),
`cargo clippy -p gpui-base --all-targets -- -D warnings`, `rustfmt
--check` on the file.

## Checklist

- [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and
followed the guidelines.
- [x] Reviewed the changes in this PR and confirmed AI generated code
(If any) is accurate.
- [ ] Passed `cargo run` for story tests related to the changes.
- [ ] Tested macOS, Windows and Linux platforms performance (if the
change is platform-specific)

The method and test in this PR were written with AI assistance (Claude).
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.

ResizableState: expose whether a handle is being dragged (is_resizing)

2 participants