Skip to content

fix(visualization): stop color range slider growing without bound - #4488

Merged
ChristianHuehn merged 1 commit into
mainfrom
fix/0/color-slider-unlimited-growth
Jun 12, 2026
Merged

fix(visualization): stop color range slider growing without bound#4488
ChristianHuehn merged 1 commit into
mainfrom
fix/0/color-slider-unlimited-growth

Conversation

@ChristianHuehn

@ChristianHuehn ChristianHuehn commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Dragging one thumb against the other could leave the slider positions crossed by a subpixel amount, because drag clamping compared screen rects while positions are stored in logical track pixels. The crossed state produced a negative segment width that the browser dropped, the overflowing segments widened the flex track, and the ResizeObserver fed the larger width back into the segments — growing the slider endlessly to the right.

Thumb clamping now happens in logical track pixels against the stored position of the other thumb, calculateSliderRangePosition clamps to 0 <= leftEnd <= rightStart <= sliderWidth, and the track segments render from widths clamped to sum exactly to the measured slider width.

{Meaningful title}

Please read the CONTRIBUTING.md before opening a PR.

Closes: #

Description

Descriptive pull request text, answering:

  • What problem/issue are you fixing?
  • What does this PR implement and how?

Definition of Done

A PR is only ready for merge once all the following acceptance criteria are fulfilled:

  • Changes have been manually tested
  • All TODOs related to this PR have been closed
  • There are automated tests for newly written code and bug fixes
  • All bugs discovered while working on this PR have been submitted as issues (if not already an open issue)
  • Documentation (GH-pages, analysis/visualization READMEs, parser READMEs, --help, etc.) has been updated (almost always necessary except for bug fixes)
  • CHANGELOG.md has been updated

Screenshots or gifs

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a visual bug in the color settings popover where the range slider thumbs could cross due to subpixel drift. This previously caused the slider track to expand unexpectedly and created visual artifacts. The slider now properly constrains thumb positions to prevent crossing and maintains correct geometry.

Dragging one thumb against the other could leave the slider positions
crossed by a subpixel amount, because drag clamping compared screen
rects while positions are stored in logical track pixels. The crossed
state produced a negative segment width that the browser dropped, the
overflowing segments widened the flex track, and the ResizeObserver fed
the larger width back into the segments — growing the slider endlessly
to the right.

Thumb clamping now happens in logical track pixels against the stored
position of the other thumb, calculateSliderRangePosition clamps to
0 <= leftEnd <= rightStart <= sliderWidth, and the track segments render
from widths clamped to sum exactly to the measured slider width.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6da2da04-28d5-4f37-a004-e6dd4dc87e1b

📥 Commits

Reviewing files that changed from the base of the PR and between 80dfe91 and e6d1c99.

📒 Files selected for processing (7)
  • plans/fix-color-slider-unlimited-growth.md
  • visualization/CHANGELOG.md
  • visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/metricColorRangeSlider.component.html
  • visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/metricColorRangeSlider.component.spec.ts
  • visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/metricColorRangeSlider.component.ts
  • visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/utils/SliderRangePosition.spec.ts
  • visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/utils/SliderRangePosition.ts

📝 Walkthrough

Walkthrough

This PR fixes unbounded growth of a color-settings range slider by preventing thumbs from crossing via logical-coordinate clamping and by deriving non-negative segment widths that always sum to the measured track width.

Changes

Color slider thumb clamping and segment rendering

Layer / File(s) Summary
Plan and documentation
plans/fix-color-slider-unlimited-growth.md, visualization/CHANGELOG.md
Establishes fix plan with three tasks (logical clamping, non-negative segments, tests) and documents the fix in the changelog.
Slider range utility: clamping and logical coordinate refactor
visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/utils/SliderRangePosition.ts, visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/utils/SliderRangePosition.spec.ts
Adds clampToRange helper; refactors calculateSliderRangePosition to clamp leftEnd and rightStart within track bounds; rewrites updateLeftThumb and updateRightThumb to use logical other-thumb positions instead of screen coordinates and applies clampToRange to prevent crossing. Tests verify clamping to bounds, crossed-thumb enforcement, and subpixel handling.
Component segment width clamping and template binding
visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/metricColorRangeSlider.component.ts, visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/metricColorRangeSlider.component.html, visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/metricColorRangeSlider.component.spec.ts
Adds segmentWidths getter that derives clamped left, middle, right widths ensuring they are non-negative and sum to measured track width. Template bindings switch to use segmentWidths object. Tests validate clamping when thumbs cross and when positions exceed track width.
Component drag handler integration
visualization/app/codeCharta/features/metricsBar/components/colorSettingsPopover/metricColorRangeSlider.component.ts
Updates left and right thumb drag handlers to pass logical other-thumb range positions to utility functions instead of screen coordinates.

A slider once wild, unchecked and free, 🐰
Growing boundless as the thumbs would flee,
Now clamped and sane, with logic in place,
Segments sum true—no growth in this race! 📏✨

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. While the author provided a good technical explanation of the bug and fix, the template structure (including the Definition of Done checklist) is not properly filled out, and the title placeholder remains. Remove the template placeholder '# {Meaningful title}' and properly complete all sections of the Definition of Done checklist with actual status indicators, and verify all required documentation has been updated.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: stopping the color range slider from growing without bound. It directly matches the primary change across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/0/color-slider-unlimited-growth

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 and usage tips.

@ChristianHuehn
ChristianHuehn merged commit 9ce1131 into main Jun 12, 2026
8 checks passed
@ChristianHuehn
ChristianHuehn deleted the fix/0/color-slider-unlimited-growth branch June 12, 2026 08:55
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.

2 participants