Skip to content

fix(search): do not warn when limit is false - #669

Open
feritcemkahraman wants to merge 1 commit into
react-component:masterfrom
feritcemkahraman:fix/search-limit-false-warning
Open

feritcemkahraman wants to merge 1 commit into
react-component:masterfrom
feritcemkahraman:fix/search-limit-false-warning

Conversation

@feritcemkahraman

@feritcemkahraman feritcemkahraman commented Oct 25, 2026 •

Copy link
Copy Markdown

Summary

Resolves #414.

In useSearchConfig, the validation check (searchConfig.limit as number) <= 0 evaluated to true when limit: false was configured because false <= 0 is true in JavaScript. This triggered a false warning ('limit' of showSearch should be positive number or false.) even though limit: false is valid and supported to disable the limit.

Changes

  • Check searchConfig.limit !== false && (searchConfig.limit as number) <= 0 before triggering the warning and resetting limit to false.
  • Add unit test in tests/search.spec.tsx verifying that limit: false does not log a warning.

Closes #414.

Summary by CodeRabbit

  • 问题修复
    • 搜索限制显式设为“不限制”时,不再触发无效值校验或开发环境警告。
    • 搜索限制设为小于或等于 0 的数值时,仍会按“不限制”处理,并在非生产环境显示警告。
  • 测试
    • 补充验证:关闭搜索限制时,渲染级联选择器不会产生错误日志。

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b92510f-9365-4f9e-bd3e-d3a583c47ff8
Commits

Reviewing files that changed from the base of the PR and between d09fcf3 and bf3e2b3.

Files selected for processing: 2
  • src/hooks/useSearchConfig.ts
  • tests/search.spec.tsx

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

当 searchConfig.limit 为 false 时,代码跳过非正数校验。新增测试验证该配置不会调用 console.error。

Changes

搜索 limit 条件修正

Layer / File(s) Summary
校验条件与测试
src/hooks/useSearchConfig.ts, tests/search.spec.tsx
limit 为 false 时跳过非正数校验。新增测试验证此配置不会调用 console.error,并在测试结束时恢复该方法。

Priority: Low

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

Change: Bug fix

Merge Risk: Minimal · up to bf3e2

The supported false limit now avoids the erroneous warning and remains mergeable.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题准确描述了主要变更:当 limit 为 false 时不再发出警告。标题简洁、明确,并与代码和测试变更一致。
Linked Issues check Passed 已链接的开放问题为 #414。src/hooks/useSearchConfig.ts 在数值校验前加入 searchConfig.limit !== false,因此 limit: false 不会触发警告或被重置。tests/search.spec.tsx 新增测试,并验证该配置不会调用 console.error。这些改动满足问题 #414 的编码要求。
Out of Scope Changes check Passed 提供的变更摘要只显示 src/hooks/useSearchConfig.ts 的一行校验修正,以及 tests/search.spec.tsx 的相关回归测试。两项变更都直接支持问题 #414。未发现无关变更。
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Finishing Touches
🧪 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

兔子翻开搜索页,
看到 limit 写着 false。
校验绕开这条路,
测试安静不报错。
兔耳轻摇收好键,
蹦跳回家吃青草。

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

This branch has not been deployed

No deployments
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.

Search limit does not work as expected

1 participant