Skip to content

refactor(ui): one edge_scroll helper scrolls the view tabs, the Browser and the Layers pane while an item is dragged (#2957) - #2988

Merged
jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:feat/2957-edge-scroll-helper
Nov 26, 2026
Merged

jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:feat/2957-edge-scroll-helper

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The view tab strip, the Browser and the Layers pane scroll their list when an item is dragged near its edge. The code was written twice, in tab_drop (mapview.rs, used by the strip and by the Browser) and in layer_drop (panes.rs): the same 28 px margin, the same 600 px/s step, the same call. It is now one helper, mapview::edge_scroll(ui, view, pointer, vertical), that both call.

No change in behaviour: the margin, the speed, the animation off and the repaint request are the ones the two copies had. tile_drop has no edge scrolling and does not get one here.

It reaches the desktop app and the browser build (the same egui code); commands, CLI, Python, scripts, plugins, the assistant, the ribbon and the phone interface are untouched, and undo is unchanged.

Not in this PR: stopping the repaint request once the list is at its end. The callers hold only the inner Ui (the Browser's is a section's body, and the Layers rows leave out the header, the basemap and the tables), so the end can't be read from the rows; it would need state kept between frames (see the issue's alternatives).

Testing

  • New a_layer_dragged_to_the_edge_of_a_long_layers_pane_scrolls_it (crates/ui-egui/tests/smoke.rs): the Layers pane had no test for its edge scrolling. With 40 layers, a layer held near the pane's bottom edge scrolls the rows up. It passes on the code before the change (the behaviour is kept, so there is no failing run to show) and fails when the helper's step is set to zero, as do the strip's and the Browser's (a_tab_dragged_to_the_edge_of_a_crowded_strip_scrolls_it, a_row_dragged_to_the_edge_of_a_long_browser_scrolls_it), which pass unchanged.
  • checks.sh 2957 rustgis-ui-egui: fmt, clippy, nextest (9625 passed), doctests, layers and schema --check all exit 0.

UI evidence

No visible UI change.

Related issue

Closes #2957.

Summary by CodeRabbit

  • Bug Fixes
    • Browser and Layers panes now scroll while you drag an item near the top or bottom edge, making it easier to move items through long lists.
    • Edge scrolling responds to how close the pointer is to the edge and stops when the pointer leaves the pane.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds a shared helper for edge-triggered scrolling during tab and layer drops. Smoke tests reuse a scrollbar lookup helper and verify drag scrolling in the Layers pane.

Changes: Drag edge scrolling

Layer / File(s) Summary
Shared edge-scrolling helper
crates/ui-egui/src/mapview.rs, crates/ui-egui/src/panes.rs
edge_scroll handles pointer bounds, edge proximity, scroll distance, and repaint requests. tab_drop and layer_drop call the helper.
Drag-scroll smoke tests
crates/ui-egui/tests/smoke.rs
The Browser test uses list_bottom to locate the scrollbar. A Layers-pane test checks that dragging a row near the bottom scrolls earlier rows upward.

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

Change: Refactor

Suggested reviewers: giswqs, pick2510

Merge Risk: Minimal · up to 99757

This change moves duplicated edge-scrolling logic for tab and layer drags into one helper and keeps the existing behavior. A new test covers the Layers pane. No merge-blocking risk was found.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#2957] Requirement 1, one helper called by the tab strip (tab_drop) and the Layers pane (layer_drop), is supported by the PR summary: mapview::edge_scroll(ui, view, pointer, vertical) is added, and l… Confirm from the base revision's tab_drop and layer_drop code how a pointer outside the list view was handled before the change (a read of the base blobs for mapview.rs and panes.rs, focused on the edge-scroll branch). If the earlier code s…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: one edge_scroll helper now handles edge scrolling for the view tab strip, the Browser, and the Layers pane during drag. It uses the conventional refactor(ui) prefix an…
Description check Passed The description follows the template. It has Summary, Testing, UI evidence, and Related issue sections. The UI evidence section states 'No visible UI change,' as the template allows. Testing lists a n…
Out of Scope Changes check Passed All changed areas connect to the issue's objective. mapview.rs adds the shared helper and makes tab_drop delegate to it. panes.rs makes layer_drop delegate to it. smoke.rs adds the Layers-pane test an…
Full details: Title check

Explanation

The title names the main change: one edge_scroll helper now handles edge scrolling for the view tab strip, the Browser, and the Layers pane during drag. It uses the conventional refactor(ui) prefix and includes the PR number. The title is specific and matches the summary and objectives.

Full details: Description check

Explanation

The description follows the template. It has Summary, Testing, UI evidence, and Related issue sections. The UI evidence section states 'No visible UI change,' as the template allows. Testing lists a new smoke test, the verification run (checks.sh with fmt, clippy, nextest, doctests, layers, schema), and the mutation-style check. Related issue reads 'Closes #2957.' The description explains the consolidation, the unchanged behaviour, and what is out of scope. It omits the 'Part of' or template placeholder wording, which is acceptable.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to the issue's objective. mapview.rs adds the shared helper and makes tab_drop delegate to it. panes.rs makes layer_drop delegate to it. smoke.rs adds the Layers-pane test and a list_bottom helper that replaces the Browser test's duplicated scrollbar lookup; this is test support for the issue's test requirement. The PR description states that commands, CLI, Python, scripts, plugins, the assistant, the ribbon, the phone interface and undo are untouched. The bounds check in the helper is part of the helper's own logic. Its behaviour effect is assessed under the linked-issue check and does not make the change out of scope.

Full details: Linked Issues check

Explanation

[#2957] Requirement 1, one helper called by the tab strip (tab_drop) and the Layers pane (layer_drop), is supported by the PR summary: mapview::edge_scroll(ui, view, pointer, vertical) is added, and layer_drop delegates to it (panes.rs, +1/-7). The issue names widgets.rs as the helper's location. The PR places it in mapview.rs; this is a location deviation that does not change behaviour. Requirement 2, no change in behaviour, is not fully established. The second commit adds a bounds check: the helper scrolls nothing for a pointer outside the view. The author states the margin, speed, animation setting and repaint request are unchanged. The original tab_drop and layer_drop code was not read, so it is unknown whether they scrolled for a pointer outside the view rect. If they did, the new check changes behaviour. Requirement 3, a Layers-pane edge-scroll test, is supplied by the new test a_layer_dragged_to_the_edge_of_a_long_layers_pane_scrolls_it (smoke.rs). The author reports it passes and fails when the step is zero; the test run was not independently verified. tile_drop is untouched, as the issue requires. The issue's non-coding and excluded items (frame-stop at list end) are not required.

Resolution

Confirm from the base revision's tab_drop and layer_drop code how a pointer outside the list view was handled before the change (a read of the base blobs for mapview.rs and panes.rs, focused on the edge-scroll branch). If the earlier code scrolled for such a pointer, either remove the bounds check or document the behaviour change against the issue's no-change requirement. If the earlier code did not scroll for it, this requirement passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit taps the list’s edge,
The rows slide up from their low ledge.
Tabs and layers share the pace,
While tests keep track of scroll and space.
The rabbit hops, then checks the view,
And finds the rows have moved anew.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6af6f2c9-220d-4ccc-9256-d7eac756cadc
Commits

Reviewing files that changed from the base of the PR and between 7182cba and 99757e9.

Files selected for processing: 3

  • crates/ui-egui/src/mapview.rs
  • crates/ui-egui/src/panes.rs
  • crates/ui-egui/tests/smoke.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

Comment thread crates/ui-egui/src/mapview.rs Resolved
Comment thread crates/ui-egui/tests/smoke.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security issues, or AGENTS.md violations. The refactor keeps the behaviour of both copies: the 28 px margin, the 600 px/s step, the stable_dt cap, the animation-off scroll, and the repaint request. Axis indexing via usize::from(vertical) maps to the same x/y as before, and the horizontal strip and vertical Browser/Layers calls resolve the same way. The tab_drop and layer_drop callers keep their pointer-in-view checks, so the helper is only reached when the pointer is inside the list.

Bugs: none found. Confidence: high.

Security: none found.

Performance: while a drag sits at the edge of a list that is already at its end, the helper requests a repaint every frame. The PR description acknowledges this and defers it. Not a new finding. Confidence: high.

Quality:

  • edge_scroll recomputes ui.clip_rect(), which both callers already hold as view, and it relies on callers checking the pointer is inside the list. Inline comment posted on mapview.rs:5004. Confidence: high.
  • The new Layers test adds its layers with map_mut().add_dataset directly rather than through the command path. The names are unique, so the test is correct. Inline comment posted on smoke.rs:1675. Confidence: high.
  • Twin gap, scoped out by the PR: tile_drop has no edge scrolling. Tile rows sit below the layers in the same Layers list, so a tile row dragged toward the bottom edge won't scroll while a layer dragged there does. This is a UX gap rather than a regression, and the PR says so explicitly. Confidence: medium that users will notice.

AGENTS.md: no violations. No unwrap/expect/panic in non-test code (the test helper's expect is in a test file). No new user-visible strings, command ids, or parameters, so the command-surface snapshot is unaffected. No wasm-only code paths changed, no saved-project or data-layer changes, and no limit-file changes.

Twins checked: the drag-scroll family. tab_drop (strip and Browser) and layer_drop (Layers) now both call edge_scroll. tile_drop does not (see above). The read routes, overlay tools, add/open commands, and wasm branches are not touched by this diff.

Prior reviews: prior-reviews.json has no threads, so I left no earlier concerns alone.

Change size

Compared: the whole PR against main (merge base 54d7854 to PR head ce90f63)

Measure Value
Files changed 3 (0 added, 3 modified, 0 removed, 0 renamed)
Size before 1.11 MB
Size after 1.11 MB
Total size change +1.4 KB
File Before After Change
crates/ui-egui/tests/smoke.rs 270.0 KB 271.2 KB +1.2 KB
crates/ui-egui/src/mapview.rs 368.1 KB 368.6 KB +548 B
crates/ui-egui/src/panes.rs 495.5 KB 495.2 KB -304 B

@github-actions

Copy link
Copy Markdown
Contributor

Code review

This PR is a behaviour-preserving refactor. The 28 px margin, the 600 px/s step, the animation-off scroll and the repaint request are unchanged. The two former copies (tab_drop in mapview.rs, layer_drop in panes.rs) now call one mapview::edge_scroll. I found no bugs, security issues or performance regressions. I did not run the tests or the build, since this environment has no shell; the checks below are by reading the code.

Bugs: None found.

  • The helper's Pos2 indexing uses a = 0 | 1 only, so it cannot go out of range.
  • view and pointer are the same values the callers already used, so the scrolling behaves as before.
  • vec2 is still used in panes.rs and Rect in mapview.rs, so the removed code leaves no unused imports, which matters under -D warnings.
  • No other copy of the edge-scroll code remains. A search for edge = 28, 600.0 * dt and push * 600 finds only the new helper.
  • Confidence: high.

Security: None.

Performance: None. The helper does no extra work beyond the old code.

Quality (low, not posted inline):

  • edge_scroll checks view.contains(pointer), but both callers already filter the pointer with the same test before calling it. The check is harmless, but it is redundant.
  • The new test a_layer_dragged_to_the_edge_of_a_long_layers_pane_scrolls_it depends on the "first scroll bar with max.x < from.x + 250" heuristic, and I could not confirm in this environment that the Layers pane's scroll bar is the one it finds. It is the same heuristic the Browser test uses, so it is consistent, but it is worth checking when the test runs.
  • Known and already raised, not repeated: the direct map_mut().add_dataset in the new test (smoke.rs, thread at line 1675), and the debug_assert!(view.contains(pointer)) suggestion (thread on mapview.rs line 5004). The earlier nit about recomputing clip_rect() is resolved, since the PR now passes view in.
  • The PR body says tile_drop gets no edge scrolling, by design. I checked the diff and left it alone.

AGENTS.md: No breaks found. The new code uses no unwrap, expect, indexing on hostile input or std::time, and needs no wasm32 split. The PR body states the surfaces it reaches and notes there is no visible change.

Earlier concerns: I left 2 alone because they were already raised: the test's direct add_dataset call and the debug_assert suggestion.

Change size

Compared with main (merge base 54d7854 to PR head 99757e9), the whole PR.

Files changed Added Modified Removed Renamed Size before Size after Total size change
3 0 3 0 0 1.1 MB 1.1 MB +1.5 KB
Path Size before Size after Size change
crates/ui-egui/tests/smoke.rs 270.0 KB 271.2 KB +1.2 KB
crates/ui-egui/src/mapview.rs 368.1 KB 368.6 KB +594 B
crates/ui-egui/src/panes.rs 495.5 KB 495.2 KB -298 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2988/
Web app https://preview.rustgis.app/pr-2988/app/
Commit 99757e9

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@jgregoriorincon
jgregoriorincon marked this pull request as ready for review November 26, 2026 02:18
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. I compared the moved body with the two removed copies. The formula, 28 px edge, 600 px/s step, stable_dt clamp, animation-off scroll and repaint request are unchanged. The only new behaviour is the view.contains(pointer) early return in edge_scroll, which both callers already apply, so it changes nothing. The vertical index maps to the same axis as before (layer_drop passes true, which is y, and tab_drop passes its existing flag). Confidence: high.

Security: None found. The change only touches egui scrolling and test code.

Performance: No new concern. The helper still requests a repaint every frame while the pointer sits in an edge zone, including at the list's end. The PR body already says this is deferred.

Quality:

  • The layers test's list_bottom helper finds the first scroll bar whose right edge is within 250 px of the drag start. That ties it to the side pane's layout. A future layout change could make it match the wrong scroll bar. Confidence: low. Left for the release quality pass.
  • The new test starts its drag at "Row Layer 40", which may be below the visible part of the 600 px pane. The test asserts only that the rows moved. I could not run it, so I cannot confirm it isn't passing for the wrong reason. Confidence: low. The PR says checks.sh passed, which I have not verified.
  • The layer test adds its layers with map_mut().add_dataset rather than the layer::add_dataset command. This was raised earlier and the author answered it, so I did not repeat it.

AGENTS.md: No breaks found.

  • No unwrap/expect/panic in non-test code.
  • The helper is shared rather than duplicated. tile_drop has no edge scrolling and is not a twin that needs it.
  • No new timer waits, ignores, or assert_eq! on identical sides.
  • The new Dataset setup builds as the other smoke tests do.
  • Nothing in the helper is platform-specific, so the wasm build should be unaffected.

Twins checked: I searched crates/ for other scroll_with_delta_animation calls and let edge = drag-scroll copies. The only remaining sites are the helper and its two callers. The overlay, read-route and wasm-branch families are not touched by this diff.

Prior reviews: Two threads already exist. Both are resolved or addressed by the author (the view parameter was adopted in 99757e9), and neither is raised again. I left both alone.

Inline comments: None posted. Nothing reaches the level of a finding worth a line-anchored comment, so the nits above are grouped here instead. I had no way to run the test suite, so the test results are unverified.

Change size

Compared: the whole PR against main (merge base 54d7854 to PR head 99757e9).

Measure Value
Files changed 3 (0 added, 3 modified, 0 removed, 0 renamed)
Size before 1133.6 KB
Size after 1135.0 KB
Total size change +1.5 KB
Path Before After Change
crates/ui-egui/tests/smoke.rs 270.0 KB 271.2 KB +1.2 KB
crates/ui-egui/src/mapview.rs 368.1 KB 368.7 KB +0.6 KB
crates/ui-egui/src/panes.rs 495.5 KB 495.2 KB −298 B

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 26, 2026
Merged via the queue into opengeos:main with commit 3b43844 Nov 26, 2026
31 checks passed
@jgregoriorincon
jgregoriorincon deleted the feat/2957-edge-scroll-helper branch November 26, 2026 02:56
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.

[Feature]: One helper scrolls a list while an item is dragged near its edge

1 participant