-
Notifications
You must be signed in to change notification settings - Fork 94
feat: add input test #768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat: add input test #768
Conversation
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds new features and test coverage to the Input component, addressing issue #697. The changes include new properties for cursor color and extra content, fixes to onChange event handling, improvements to input validation behavior, and comprehensive test cases.
- Adds
cursorColor
andextra
properties to the Input component - Fixes onChange context and trigger type issues, adding 'blur' trigger support
- Improves input validation behavior for
allowInputOverMax
and composition input handling - Adds comprehensive test coverage for the Input component
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/input/type.ts | Adds cursorColor and extra property definitions, updates onChange trigger types |
src/input/input.md | Updates documentation for new properties and onChange trigger types |
src/input/input.en-US.md | Updates English documentation for new properties and onChange trigger types |
src/input/defaultProps.ts | Adds default value for cursorColor property |
src/input/tests/input.test.tsx | Adds comprehensive test suite covering all Input component functionality |
src/input/Input.tsx | Implements new features, fixes input handling logic, and improves event management |
src/_util/useDefault.ts | Extends hook to return additional update function for internal state management |
site/test-coverage.js | Updates test coverage metrics for Input component |
Comments suppressed due to low confidence (1)
src/input/Input.tsx:1
- The maxLength attribute has been removed but the logic that calculates
resultMaxLength
is still present in the component. This creates a disconnect between the UI constraint and the component's internal validation logic, potentially causing inconsistent behavior.
import type { ChangeEvent, CompositionEvent, CSSProperties, FocusEvent, FormEvent, TouchEvent } from 'react';
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/input/Input.tsx
Outdated
if (nativeEvent.isComposing || nativeEvent.inputType === 'insertCompositionText') { | ||
updateValue(finalValue); |
Copilot
AI
Sep 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During composition input, updateValue(finalValue)
is called but onChange is not triggered. This creates inconsistency where the internal state updates but parent components don't receive the change notification, potentially causing state synchronization issues.
if (nativeEvent.isComposing || nativeEvent.inputType === 'insertCompositionText') { | |
updateValue(finalValue); | |
setInnerValue(finalValue, { e, trigger: 'input' }); |
Copilot uses AI. Check for mistakes.
src/input/Input.tsx
Outdated
|
||
const [showClear, setShowClear] = useState<boolean>(false); | ||
const [innerValue, setInnerValue] = useDefault(value, defaultValue, onChange); | ||
const [innerValue, setInnerValue, updateValue] = useDefault(value, defaultValue, onChange); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
受控逻辑直接换用 useControlled,与 pc 端保持一致,其他组件也会切换过去
5a4c14a
to
00197c4
Compare
00197c4
to
d756721
Compare
/update-common |
1 similar comment
/update-common |
/update-snapshot |
⏳ 正在运行快照更新。。。 CI: Open |
🤔 这个 PR 的性质是?
🔗 相关 Issue
#697
💡 需求背景和解决方案
📝 更新日志
feat(input): 新增cursorColor和extra特性
fix(input): 修复onChange的context为空、allowInputOverMax不生效、「中文输入的时候禁止触发」不生效、clearTrigger=focus不生效问题
本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单