Skip to content

fix: skip changes for unchanged switch values - #183

Merged
afc163 merged 1 commit into
react-component:masterfrom
feritcemkahraman:fix/skip-unchanged-arrow-values
Oct 19, 2026
Merged

afc163 merged 1 commit into
react-component:masterfrom
feritcemkahraman:fix/skip-unchanged-arrow-values

Conversation

@feritcemkahraman

@feritcemkahraman feritcemkahraman commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Pressing ArrowRight on an already checked switch, or ArrowLeft on an unchecked switch, emits onChange even though the value stays the same.

Skip requests for the existing value in the shared change handler. Actual keyboard/click changes, onKeyDown/onClick callbacks and controlled change requests keep working.

Validation: all three regressions failed before the fix; all 17 tests pass with 100% statement/line/function coverage. Full TypeScript and ESLint pass (one existing documentation warning), and changed-file Prettier passes. ESM/CJS and declaration compilation plus the Less CSS build pass. The documentation-site build and real-browser matrix were not run.

Summary by CodeRabbit

  • Bug Fixes
    • 开关禁用或目标状态未变化时,不再更新状态或触发变更回调。
    • 修正键盘操作和点击操作的回调行为;受控模式下,仅状态变更请求会触发回调。
  • Tests
    • 增加测试,覆盖箭头键、点击操作及受控模式下的状态变更行为。

@vercel

vercel Bot commented Oct 18, 2026

Copy link
Copy Markdown

@feritcemkahraman 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 Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca3f864d-56f6-4461-ba8e-ea1d76291cc8
📥 Commits

Reviewing files that changed from the base of the PR and between ac3c285 and 7cf273e.

📒 Files selected for processing: 2
  • src/index.tsx
  • tests/index.spec.js

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Walkthrough

triggerChange 现在仅在开关未禁用且目标状态不同于当前状态时更新状态并调用 onChange。新增测试覆盖非受控和受控模式下的键盘及点击行为。

Changes

开关状态变更回调

Layer / File(s) Summary
状态变更条件与交互测试
src/index.tsx, tests/index.spec.js
triggerChange 仅在状态发生变化时更新状态并调用 onChange。新增测试验证箭头键、点击及受控模式下的回调行为。

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 7cf27

The switch change is ready to merge after normal checks; no outstanding behavior issue was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed 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 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题准确概括了本次变更的主要目的:当开关值未变化时跳过变更处理。标题简洁且与代码和测试变更一致。
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 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

小兔按下方向键,
状态未变,回调歇。
目标改变才通知,
点击也把事件写。
测试守着每一步,
月光下,开关轻轻跃。

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

@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ac3c285) to head (7cf273e).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #183   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           32        32           
  Branches         8         8           
=========================================
  Hits            32        32           

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

@afc163
afc163 merged commit dd99fb1 into react-component:master Oct 19, 2026
9 of 10 checks passed
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