Skip to content

fix(swipe): correct layer order, basemap label, and pause behavior (#842)#859

Merged
giswqs merged 2 commits into
mainfrom
fix/issue-842-swipe-panel
Jun 25, 2026
Merged

fix(swipe): correct layer order, basemap label, and pause behavior (#842)#859
giswqs merged 2 commits into
mainfrom
fix/issue-842-swipe-panel

Conversation

@giswqs

@giswqs giswqs commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the three Layer Swipe panel inconsistencies reported in #842:

  1. Inverted layer order. The panel's LEFT LAYERS / RIGHT LAYERS lists were in reverse stack order (bottom layer at the top). They now mirror the main layer manager, with the top-most layer first and the base layer at the bottom.
  2. Basemap label. The grouped base layer was labeled Basemap while the main interface calls it Background. The swipe panel relabeling helper now uses Background to match.
  3. Pause behavior. Toggling Swipe Enabled off tore down the entire split-screen comparison. It now freezes the comparison in place and locks the slider (dragging disabled, handle dimmed), keeping the side-by-side view and its layer/orientation controls meaningful.

Changes

Testing

  • Verified in the running app (web) with two XYZ overlays plus the basemap, in both light and dark themes:
    • Lists read Beta, Alpha, Background top-to-bottom, matching the sidebar.
    • The base layer shows as Background.
    • Toggling Swipe Enabled off keeps the split view on screen with a locked slider; toggling on restores dragging.
  • npm run build and pre-commit run --files (eslint + npm build) pass.

Fixes #842

)

The Layer Swipe panel disagreed with the main interface in three ways:

- Its LEFT/RIGHT lists were in reverse stack order, and toggling Swipe
  Enabled off tore down the whole split view instead of just locking the
  slider. Both are fixed upstream in maplibre-gl-swipe 0.10.1, which this
  bumps to: the lists now mirror the layer manager (top layer first) and a
  paused swipe freezes the comparison in place with a locked slider.
- The grouped base layer was labeled "Basemap" while the main layer manager
  calls it "Background". The panel relabeling helper now uses "Background"
  to match.

Fixes #842
@netlify

netlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploy Preview for geolibre-app ready!

Name Link
🔨 Latest commit 899b006
🔍 Latest deploy log https://app.netlify.com/projects/geolibre-app/deploys/6a3c97eda964530008f32b4b
😎 Deploy Preview https://deploy-preview-859--geolibre-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@giswqs, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 26 minutes and 3 seconds. Learn how PR review limits work.

To continue reviewing without waiting, enable usage-based billing in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 07c35124-82b4-45bd-9a71-a5a1c7838935

📥 Commits

Reviewing files that changed from the base of the PR and between e1aaf07 and 899b006.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • apps/geolibre-desktop/package.json
  • apps/geolibre-desktop/src/lib/swipe-style.ts
  • packages/plugins/package.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-842-swipe-panel

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

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

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

⚡ Cloudflare Pages preview

Item Value
Preview https://ddff316b.geolibre-preview.pages.dev
Demo app https://ddff316b.geolibre-preview.pages.dev/demo/
Commit c963c43

Comment on lines +262 to +263
// Mirror the main layer manager, which labels the base layer "Background"
// rather than "Basemap" (see issue #842).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CLAUDE.md says comments must be at most one short line, and must not reference issue numbers (those belong in the PR description and rot over time). The two-line block and the (see issue #842) citation both violate those rules.

Suggested change
// Mirror the main layer manager, which labels the base layer "Background"
// rather than "Basemap" (see issue #842).
// Matches the label used by the main layer manager for the grouped base layer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed the comment: it is now a single short line with no issue reference (899b006). On the i18n note, agreed it is the same hardcoded-English pattern the file already uses for its other labels; routing the translated base-layer label through the __GEOLIBRE_LAYER_LABELS__ bridge is a good follow-up and I will open a separate issue for it rather than expand this fix.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Opened #860 to track the localization follow-up.


// Mirror the main layer manager, which labels the base layer "Background"
// rather than "Basemap" (see issue #842).
const SWIPE_BASEMAP_LABEL = "Background";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i18n gap (medium confidence). The main layer manager renders this label through t("layers.background") (LayerPanel.tsx:2075). Because swipe-style.ts runs outside the React tree it can't call t(), so the string is hardcoded in English. In a non-English locale the swipe panel will always show "Background" while the sidebar shows the translated label.

The existing __GEOLIBRE_LAYER_LABELS__ / geolibre-layer-labels-change bridge (populated by map-controller.ts) is the natural extension point: the publisher could include a __basemap__ entry keyed to the already-translated string, letting this file stay DOM-only while picking up the correct locale. That is out of scope here, but a follow-up issue would keep the two surfaces in sync across locales.

No code change required for this PR; leaving as a note.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs / Logic Errors

None found. The three behavioural fixes (inverted layer order, pause behavior) are correctly delegated to the upstream maplibre-gl-swipe@0.10.1 bump; the local code change only addresses the label rename.

Security

Nothing to flag. All DOM writes in swipe-style.ts use textContent (not innerHTML), and the selector constructed with CSS.escape was not touched.

Performance

Nothing to flag.

Quality

  • i18n gap – medium confidence. SWIPE_BASEMAP_LABEL = "Background" is a hardcoded English string. The main layer manager renders the same label via t("layers.background") (LayerPanel.tsx:2075), so in a non-English locale the two panels will disagree. The __GEOLIBRE_LAYER_LABELS__ / geolibre-layer-labels-change bridge (published by map-controller.ts) is the natural extension point: adding a __basemap__ entry with the already-translated string would let swipe-style.ts stay DOM-only while picking up the correct locale. Flagged inline as a follow-up opportunity; not blocking.

CLAUDE.md

  • Comment style violation – high confidence. Lines 262–263 are a two-line block that also cites issue #842 by number. CLAUDE.md requires at most one short comment line and explicitly prohibits issue references in code comments. Flagged inline with a one-line suggestion.

Verified clean

  • package-lock.json integrity hashes are both valid 88-char base64 SHA-512 values.
  • The version bump is applied consistently across all three locations (apps/geolibre-desktop/package.json, packages/plugins/package.json, package-lock.json).
  • The SWIPE_BASEMAP_LABEL constant correctly replaces both occurrences of the old "Basemap" literal (label text and tooltip).

layerId === "__basemap__" ? "Basemap" : `${displayName} (${layerId})`;
layerId === "__basemap__"
? SWIPE_BASEMAP_LABEL
: `${displayName} (${layerId})`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit – tooltip is now identical to the label for the basemap

For every other layer the tooltip is "displayName (layerId)", giving a hover hint with the raw layer ID. For __basemap__ the tooltip becomes "Background" – the same text as the visible label – so hovering adds no information.

Exposing the internal sentinel __basemap__ directly would be confusing, but a short disambiguating phrase would make the tooltip meaningful without leaking internals:

Suggested change
: `${displayName} (${layerId})`;
? `${SWIPE_BASEMAP_LABEL} (base layer)`

Low urgency – the pre-existing code had the same pattern (just with "Basemap" for both label and tooltip) – but worth fixing while this line is in motion.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Scope: 14 additions / 9 deletions across swipe-style.ts, two package.json files, and the lock file. Changes are surgical and easy to follow.


Bugs

None found. The constant extraction in getSwipeLayerLabel and syncSwipeLayerLabels eliminates the previous duplication between the two callers and the logic is correct.

Security

None found. No user input is evaluated; the DOM writes are plain text assignments (textContent, title), so no XSS risk.

Performance

None found. The MutationObserver + rAF debounce pattern is unchanged; the label fix is inside the existing syncSwipeLayerLabels loop with no extra DOM queries.

Quality

Finding Confidence
Tooltip equals label for __basemap__ – after the change, label.title is set to "Background", which is identical to label.textContent. For all other layers the tooltip appends (layerId) to give a hover hint with the internal ID. This was also true before the PR ("Basemap" for both), but worth cleaning up while the line is in motion. Inline suggestion posted. Medium
SWIPE_BASEMAP_LABEL is a hardcoded English string – CLAUDE.md requires t() for new user-facing strings. However, swipe-style.ts is a plain DOM-manipulation module with no React context, and map-controller.ts:1275 already uses the identical hardcoded "Background" for the same concept without t(). This is a pre-existing architectural gap, not a regression introduced here. Low

CLAUDE.md

  • i18n – as noted above, the "Background" constant is consistent with existing non-React modules that have the same limitation. No new violation introduced by this PR.
  • No direct main commit, no new external hosts, comment style – all look fine.

Package bump (maplibre-gl-swipe 0.10.0 → 0.10.1)

The lock file is updated consistently across both workspace entries and the single resolved node module. The SHA-512 SRI hash is well-formed (88-character base64). The bump satisfies the >=0.7.1 peer-dependency range in maplibre-gl-components. No concerns.


Overall this is a clean, focused fix. The one inline comment is a nit on the tooltip; everything else looks correct.

@giswqs giswqs merged commit 96171e0 into main Jun 25, 2026
23 checks passed
@giswqs giswqs deleted the fix/issue-842-swipe-panel branch June 25, 2026 02:59
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.

UI Bug Report: Layer Swipe Window Displays Inverted Layer Order, Incorrect Background Label, and Broken Toggle Workflow

1 participant