Skip to content

fix: render numeric zero input affixes - #201

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/render-zero-affixes
Open

fix: render numeric zero input affixes#201
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/render-zero-affixes

Conversation

@nrps9909

@nrps9909nrps9909 commented Aug 27, 2026

Copy link
Copy Markdown

Summary

  • preserve numeric 0 values in prefix, suffix, addonBefore, and addonAfter
  • keep wrapper detection, rendered slots, and suffix-related classes on the same content predicate
  • add a rerender regression that covers all four public ReactNode slots and wrapper cleanup

Why

These four public props accept ReactNode, and React renders numeric zero. The shared hasPrefixSuffix / hasAddon helpers and the corresponding render conditions currently rely on truthiness, so passing 0 removes both the content and the structural wrapper needed for its styles.

On exact base 52086bb9f34b03abcb3822f971b180bd5a90e79a, the new regression failed because the prefix query returned null. It passes after the fix, and the null / false rerender still removes both wrapper layers.

Validation

  • rc-test --no-watchman --runInBand — 10 suites, 128 tests, 22 snapshots
  • tsc --noEmit
  • focused ESLint — zero warnings
  • full source ESLint — zero errors and two existing ResizableTextArea.tsx hook warnings
  • Prettier check
  • ESM, CJS, declaration, and Less compilation
  • git diff --check

Overlap audit

The only current open PR touching src/BaseInput.tsx is the unrelated copy-feature proposal #40 from 2021. It does not change hasPrefixSuffix, hasAddon, or any of the four conditions in this fix. I found no open issue or PR targeting numeric-zero affix or addon content.

AI assistance disclosure: Codex was used to audit open overlap, trace the duplicated truthiness checks, draft the regression and minimal shared predicate, and run the validation listed above. The exact-base failure and fixed behavior were verified locally.

Summary by CodeRabbit

  • Bug Fixes
    • 修复输入框无法正确显示数值 0 作为前缀、后缀或附加内容的问题。
    • 优化内容存在性判断,确保空值不会错误渲染对应包装元素。
  • Tests
    • 新增测试,覆盖数值 0 的渲染,以及内容设为 nullfalse 时相关元素的隐藏。

@vercel

vercelBot 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

coderabbitaiBot commented Aug 27, 2026

Copy link
Copy Markdown

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: 1dea5315-0924-45d6-9722-638259c168bf

📥 Commits

Reviewing files that changed from the base of the PR and between 52086bb and b53dfd6.

📒 Files selected for processing (3)
  • src/BaseInput.tsx
  • src/utils/commonUtils.ts
  • tests/BaseInput.test.tsx

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

本次变更新增 hasContent,使数值 0 被识别为有效内容。BaseInput 使用该函数统一处理 prefix、suffix 和 addon。测试覆盖数值 0 的渲染及空内容的移除。

Changes

输入装饰内容判定

Layer / File(s)Summary
内容判定工具
src/utils/commonUtils.ts
新增 hasContenthasAddonhasPrefixSuffix 使用该函数判断内容是否存在。
BaseInput 装饰内容渲染
src/BaseInput.tsx, tests/BaseInput.test.tsx
BaseInput 使用 hasContent 控制 prefix、suffix、addon 的渲染和相关 class。测试验证数值 0 的渲染,以及 nullfalse 内容的移除。

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

Merge Risk:⚪ Minimal · up to b53df

This localized change makes numeric zero render correctly in existing input decoration slots while preserving null and false cleanup behavior. No actionable merge-blocking risk remains after normal checks and review.

Poem

小兔看到零值闪亮,
前缀后缀稳稳登场。
addon 排成一列,
空内容悄悄退场。
hasContent 让判断清爽。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ Passed标题准确概括了主要变更:修复数值 0 作为输入附加内容时的渲染问题。标题简洁、明确,并与代码和测试变更一致。
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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 💡
  • 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 freeto 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.

1 participant

@nrps9909