Skip to content

fix(layout): keep a legend's Reset in reach when it lists no layer but leaves one out - #3375

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3358-legend-reset-no-rows
Nov 29, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3358-legend-reset-no-rows

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A legend's Format › Layers section showed only when the legend could list a layer or had an order of its own. A legend that listed none (a map whose only layer is a raster on a color ramp) but left one out had no section, so no Reset, and only a script could clear the name left out.

The section now also shows while the legend leaves out a layer the map still has. With nothing to list it holds just Reset, which clears the names left out; the section then goes away. A name left out that is no longer on the map doesn't bring the section up. Legends that list layers are unchanged.

Reach: the change is in the shared Format pane (ui-egui), so it applies wherever that pane shows, in the desktop app and the browser. The touch interface (ui-touch) has no legend layer list. The command line, Python, scripts, the assistant and plugins already clear the names with layout.update ("exclude": []), so no command, parameter or tool description changes. Reset is one undo step, as before.

Testing

  • a_legend_listing_no_layer_can_still_be_reset now covers a layer left out as well as an order of its own. It fails without the fix (no Reset to click) and passes with it. It also pins that a left-out name the map no longer has brings no section up.
  • cargo fmt --check, clippy, cargo nextest (11049 passed, 29 skipped), doctests, cargo xtask layers and cargo xtask schema --check pass locally; after the later test-only changes, fmt, rustgis-ui-egui clippy and this test again.
  • ui_shot replay on a map holding one raster on a ramp, left out of the legend, before and after.

UI evidence

The bottom of the legend's Format pane. From left to right: before; after; after Reset.

3358-before-after.png

Related issue

Closes #3358

Summary by CodeRabbit

  • Bug Fixes
    • The Layers section now remains visible when saved layer ordering or exclusions still apply, even if no layer names are currently available to list.
    • Reset is available when saved ordering or retained exclusions exist, and clears both. If only an outdated exclusion remains, the Layers section and Reset button are hidden.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The legend Layers section now appears when retained exclusions exist, even if no layer names are listable. Reset clears the saved layer order and exclusions. Tests cover reset behavior and a stale excluded name.

Changes: Legend reset behavior

Layer / File(s) Summary
Layers section visibility and Reset behavior
crates/ui-egui/src/layoutview/format/legend.rs, crates/ui-egui/src/layoutview/tests.rs
The Layers section appears when names, saved ordering, or retained exclusions exist. Tests verify that Reset clears the order and exclusions when no names are listable, and that a stale excluded name alone does not show the section or Reset.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • Issue 3321 asks for a Reset control in the legend’s Layers section. This change covers Reset for excluded layers, but not Select All or Select None.

Possibly related PRs

  • opengeos/RustGIS#3350: Both changes address excluded names and Reset behavior in the legend’s Format Layers section.
  • opengeos/RustGIS#3296: Both changes affect the Format Layers section’s visibility and reset-related behavior.

Suggested reviewers: m-hollis-1

Merge Risk: Minimal · up to 46146

The legend Layers section and its Reset button now stay available when a legend excludes a layer that is still on the map but lists none. This is a small, localized UI change with tests for the reset and stale-name cases, and no merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and its scope: the legend's Reset stays reachable when the legend lists no layer but leaves one out. This matches the raw summary, where the Layers section now shows for exclud…
Description check Passed The description follows the template. It has a Summary that explains the problem, the fix, and the scope. It has a Testing section that lists the test, the checks run, and a ui_shot replay. It has a U…
Linked Issues check Passed [#3358] requires the legend's Layers section and Reset to appear when the legend lists no layer, has no custom order, and leaves a map layer out. At head, `crates/ui-egui/src/layoutview/format/legend.…
Out of Scope Changes check Passed The PR changes crates/ui-egui/src/layoutview/format/legend.rs (section visibility, Reset enablement and clearing) and crates/ui-egui/src/layoutview/tests.rs (the Reset test and its setup helper). …
Full details: Title check

Explanation

The title names the fix and its scope: the legend's Reset stays reachable when the legend lists no layer but leaves one out. This matches the raw summary, where the Layers section now shows for excluded or ordered names still on the map, and Reset clears exclude and layerOrder. The title is specific and concise. It uses the conventional fix(layout) prefix and does not describe anything absent from the changeset.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains the problem, the fix, and the scope. It has a Testing section that lists the test, the checks run, and a ui_shot replay. It has a UI evidence section with before and after images, which the template requires for visible UI changes. It has a Related issue section that closes #3358. The template's UI evidence section is required, and the author supplied screenshots for it. The PR objectives describe a different sidebar image set, but that does not affect the author's description content.

Full details: Linked Issues check

Explanation

[#3358] requires the legend's Layers section and Reset to appear when the legend lists no layer, has no custom order, and leaves a map layer out. At head, crates/ui-egui/src/layoutview/format/legend.rs computes kept as the excluded names that the map still has, including rasters on a ramp that the legend does not list. The section is drawn when !names.is_empty() || !layer_order.is_empty() || !kept.is_empty(), so a legend with only a kept exclusion now shows Layers. The Reset change, per the PR description and the AI-generated summary, clears both exclude and layerOrder. The test a_legend_listing_no_layer_can_still_be_reset covers this case, and a stale excluded name that is no longer on the map does not show the section. The Reset button logic was truncated in the repository read, so its exact clearing behavior rests on the PR description and summary, not on a directly read hunk. The rest of the issue is met.

Full details: Out of Scope Changes check

Explanation

The PR changes crates/ui-egui/src/layoutview/format/legend.rs (section visibility, Reset enablement and clearing) and crates/ui-egui/src/layoutview/tests.rs (the Reset test and its setup helper). Both directly implement or test [#3358]. The PR description reports no change to commands, parameters, or tool descriptions, and no change to ui-touch. No unrelated change was identified. Full diff inspection of the Reset hunk was not possible, so this verdict relies on the summary for that hunk.

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 checks the Layers pane,
No names to show, yet exclusions remain.
Reset clears the order and names,
The section hides when nothing claims.
The rabbit hops through tidy frames.

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: c8fb5a51-6eb0-4399-8d15-4ddfdd9dd049
Commits

Reviewing files that changed from the base of the PR and between 713d33a and 4614666.

Files selected for processing: 2

  • crates/ui-egui/src/layoutview/format/legend.rs
  • crates/ui-egui/src/layoutview/tests.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.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

No bugs, security, performance or AGENTS.md problems found in the changed lines. I left no inline comments because I found nothing that needs one.

Bugs: none found.

  • legend.rs:170 shows the section when the legend has no rows to list but leaves out a name the map still has (kept). Reset (legend.rs:313) then clears both exclude and layerOrder, so the Reset-only case works. Confidence: high.
  • The test helper's exclude edit goes straight into the project struct, bypassing layout.update. That is fine for a test that needs a name only a file can hold, and the comment says so. Confidence: high.

Security: none found. No new input handling; exclude names are only compared, never used as paths or commands.

Performance: none found. kept is one filter over exclude, the same cost as the existing unlisted line.

Quality: none worth an inline comment.

  • Pre-existing, not changed by this PR: a stale layerOrder name (one the map no longer has) still opens the section and shows Reset, because legend.rs:170 tests layer_order without filtering it through on_map. Only exclude gets that filter. The new test's rule that a name the map no longer has "brings no section up" therefore covers exclude only. Stale layerOrder names can only come from a file, so I am leaving this alone.

AGENTS.md: no violations.

  • No unwrap or panic is added to non-test code. The unwraps and panic! are in the test helper.
  • No wasm, command-surface, schema, or new-string issues apply. The change is in the shared Format pane, which the PR says covers the desktop and browser. The touch UI has no legend layer list.
  • Test hygiene: the assertions compare a computed value with a fixed expected value, and there are no timer waits.

Twins checked: the touch interface (ui-touch) has no legend layer list, so it has no twin for this change. No twin in the listed families (read routes, overlay tools, add/open commands, or wasm/desktop branches) is touched. I found no sibling that needs the same change.

Prior reviews: the review-thread file lists no threads, so there were no earlier concerns to leave alone.

Change size

Compared: the whole PR against main (merge base 92594ee to PR head 4614666).

Measure Value
Files changed 2 (added 0, modified 2, removed 0, renamed 0)
Size before 178.1 KB (182,350 B)
Size after 179.2 KB (183,453 B)
Total size change +1.1 KB (+1,103 B)
Path Before After Change
crates/ui-egui/src/layoutview/tests.rs 160.4 KB 161.4 KB +1.0 KB (+1,060 B)
crates/ui-egui/src/layoutview/format/legend.rs 17.7 KB 17.8 KB +43 B

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3375/
Web app https://preview.rustgis.app/pr-3375/app/
Commit 4614666

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).

Merged via the queue into opengeos:main with commit b82eff1 Nov 29, 2026
28 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3358-legend-reset-no-rows branch November 29, 2026 20:40
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.

[Bug]: A legend's Reset is out of reach when it lists no layer but leaves one out

1 participant