Skip to content

fix: preserve pushable gaps on track clicks - #1092

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/track-click-pushable
Open

fix: preserve pushable gaps on track clicks#1092
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/track-click-pushable

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • route track-click value changes through the same offsetValues constraints used by drag and keyboard movement
  • preserve pushable gaps for both existing ranges and editable handle insertion
  • retain the existing empty-range initialization path

Fixes #200.

Problem

Track clicks currently replace or insert the nearest value directly, bypassing the pushable algorithm. With [20, 40] and pushable={20}, clicking 30 emits [20, 30]; editable mode emits [20, 30, 40]. Both results violate the documented minimum adjacent gap.

The corrected path keeps the clicked value at 30 and pushes its neighbors through the existing distance-mode algorithm, producing [10, 30] and [10, 30, 50] respectively. Non-range, disabled, allow-cross, and null-range paths continue through their existing branches; the full suite covers those boundaries.

Verification

  • Exact base: 02260ea7a23e09a76f34d9c59d41c9aae8561140
  • Regression proof: with only the two new tests applied to the exact base, both fail with [20, 30] / [20, 30, 40] instead of [10, 30] / [10, 30, 50]
  • npm test -- --runInBand — 5/5 suites, 123/123 tests, 5/5 snapshots passed
  • npm run tsc — passed
  • npm run lint — passed
  • npm run compile — passed
  • git diff --check and source Prettier check — passed

The full test run retains the repositorys existing React act(...) console warnings; it has no test failures.

Overlap audit

Open PR #1091 changes Range.test.tsx for the independent decimal-distance comparison and places its test in a separate section. #1089 changes drag-completion coverage. The old #1055, #866, and #766 branches touch Slider.tsx for deprecated APIs, mark/step memoization, and cursor styling; none changes track-click constraint handling.

AI assistance disclosure

Codex was used to reproduce the old report on current master, trace the click and offset paths, implement the focused reuse of existing constraints, audit open file overlaps, and run the verification above. I reviewed the diff and results before submitting.

Summary by CodeRabbit

  • 问题修复
    • 修复点击刻度或轨道时未正确遵循 pushable 约束的问题。
    • 确保点击轨道和在可编辑模式下新增滑块后,各滑块之间保持正确间距。

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.68%. Comparing base (02260ea) to head (2c641e3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1092      +/-   ##
==========================================
+ Coverage   98.66%   98.68%   +0.01%     
==========================================
  Files          15       15              
  Lines         751      761      +10     
  Branches      224      239      +15     
==========================================
+ Hits          741      751      +10     
  Misses         10       10              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 54f23dfb-2384-4020-b424-3c1a3c0e2661

📥 Commits

Reviewing files that changed from the base of the PR and between 02260ea and 2c641e3.

📒 Files selected for processing (2)
  • src/Slider.tsx
  • tests/Range.test.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


Walkthrough

本次修改更新 changeToCloseValue,使轨道点击和可编辑句柄插入遵循 pushable 约束,并新增对应测试。

Changes

轨道点击约束

Layer / File(s) Summary
点击值更新逻辑
src/Slider.tsx
rawValues 为空时直接插入新值。替换已有句柄时,通过 offsetValues 应用值偏移和 pushable 约束。
点击场景验证
tests/Range.test.tsx
新增轨道点击和可编辑句柄插入测试,验证最终值分别为 [10, 30][10, 30, 50]

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

Merge Risk: ⚪ Minimal · up to 2c641

Track clicks now preserve the documented minimum gaps for pushable ranges without changing public APIs or deployment behavior. The change is merge-ready after normal checks, with no actionable merge-blocking risk remaining.

Poem

小兔点击刻度线,
数值沿着轨道转。
pushable 守住距离,
新旧句柄排整齐。
测试轻敲鼠标键,
结果清晰又安全。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更,即修复轨道点击时保持 pushable 间距。标题简洁且与代码和测试变更一致。
Linked Issues check ✅ Passed 代码通过在轨道点击处理中复用 offsetValues 约束,防止点击操作绕过 pushable 最小间距。新增测试覆盖现有范围和 editable 模式下的手柄插入,满足 Issue #200 的目标。
Out of Scope Changes check ✅ Passed 所有变更均围绕 Issue #200 展开,包括轨道点击逻辑修复和对应回归测试。未发现无关或超出范围的代码变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

Pushable feature - min range can be skipped with axis click

1 participant