Skip to content

fix: preserve decimal pushable gaps - #1091

Open
nrps9909 wants to merge 3 commits into
react-component:masterfrom
nrps9909:codex/audit-decimal-pushable
Open

fix: preserve decimal pushable gaps#1091
nrps9909 wants to merge 3 commits into
react-component:masterfrom
nrps9909:codex/audit-decimal-pushable

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • compare pushable gaps with a magnitude-scaled floating-point tolerance
  • avoid pushing decimal handles more than one aligned step when their gap is already equal to pushable
  • add a mouse-drag regression that pushes a three-handle range in both directions

Fixes #227.

Problem

Aligned decimal values can still produce an inexact result when subtracted. For example, 0.7 - 0.6 is slightly less than 0.1, so the current raw dist < pushable check treats an already valid gap as too small and pushes the surrounding handle again. Dragging [0.5, 0.6, 0.7] one step to the right therefore jumps to [0.6, 0.8, 1] instead of [0.6, 0.7, 0.8].

The tolerance is scaled from the compared handle values and configured gap, so it only absorbs representational noise at their magnitude; genuinely smaller gaps continue through the existing push loop.

Verification

  • Exact base: 02260ea7a23e09a76f34d9c59d41c9aae8561140
  • Regression proof: on the exact base, the new mouse-drag test fails with [0.6, 0.8, 1] instead of [0.6, 0.7, 0.8]
  • npm test -- --runInBand — 5/5 suites, 122/122 tests, 5/5 snapshots passed
  • npm run tsc — passed
  • npm run lint — passed
  • npm run compile — passed
  • git diff --check — passed

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

Overlap audit

Open PR #904 touches useOffset.ts in the separate allowCross={false} branch and does not change the pushable distance comparison. Open PRs #1055 and #1089 touch Range.test.tsx for unrelated deprecated-API and drag-completion coverage. No open PR implements the decimal-gap correction.

AI assistance disclosure

Codex was used to reproduce the old report on current master, trace the current push loop, implement the tolerance, audit overlapping open PR files, and run the verification above. I reviewed the diff and results before submitting.

Summary by CodeRabbit

  • Bug 修复

    • 修复小数步长场景下,拖动范围滑块时相邻句柄无法准确推动的问题。
    • 提升十进制数值对齐的计算准确性,避免浮点误差导致错误判断。
  • 测试

    • 新增双向拖动小数句柄的验证,确保句柄按预期步长更新。

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@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: 0372f233-22f3-4bce-b560-32a4a8f144e1

📥 Commits

Reviewing files that changed from the base of the PR and between 6c9b24b and e6bf453.

📒 Files selected for processing (1)
  • src/hooks/useOffset.ts

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


Walkthrough

Changes

小数句柄推挤

Layer / File(s) Summary
推挤距离与容差处理
src/hooks/useOffset.ts
needPush 现在接收两个端点值,并使用按数值量级缩放的 Number.EPSILON 容差判断推挤条件。四个推挤循环改为传入端点值。
双向小数推挤测试
tests/Range.test.tsx
新增测试,验证 step=0.1pushable=0.1 时,句柄可向右和向左推动相邻句柄。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to e6bf4

The PR preserves valid decimal gaps using a magnitude-scaled tolerance and adds regression coverage for dragging in both directions. With the listed tests and checks passing, no actionable merge-blocking risk remains beyond normal review.

Poem

小兔检查小数句柄
左推右推都按步长
容差处理浮点误差
相邻句柄依次移动
新测试记录两种方向

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题“fix: preserve decimal pushable gaps”准确概括了修复小数 pushable 间距处理的主要变更,简洁且明确。
Linked Issues check ✅ Passed 代码在 gap 比较中加入按数值量级缩放的浮点容差,修复小数 step 下正向和负向拖动的 pushable 行为。新增测试覆盖两个方向,满足问题 #227 的要求。
Out of Scope Changes check ✅ Passed 变更仅涉及 pushable 间距计算和对应的鼠标拖动回归测试。所有变更都与问题 #227 直接相关,未发现范围外修改。
  • Fix all pre-merge checks with AI
✨ 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.

@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.67%. Comparing base (02260ea) to head (e6bf453).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1091   +/-   ##
=======================================
  Coverage   98.66%   98.67%           
=======================================
  Files          15       15           
  Lines         751      755    +4     
  Branches      224      235   +11     
=======================================
+ Hits          741      745    +4     
  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.

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 only works in positive direction with decimal steps

1 participant