-
-
Notifications
You must be signed in to change notification settings - Fork 490
fix: Select with `` value #1207
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
+10
−1
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -273,6 +273,15 @@ describe('Select.Basic', () => { | |
| expect(container.querySelector('.rc-select-content-has-option-style')).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('should not add -content-has-value className when value is empty string', () => { | ||
| const { container } = render( | ||
| <Select value=""> | ||
| <Option value="1">One</Option> | ||
| </Select>, | ||
| ); | ||
| expect(container.querySelector('.rc-select-content-has-value')).toBeFalsy(); | ||
| }); | ||
|
Comment on lines
+276
to
+283
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 针对空字符串值的测试用例很好。为了防止回归并确保数值 it('should add -content-has-value className when value is 0', () => {
const { container } = render(
<Select value={0}>
<Option value={1}>One</Option>
</Select>,
);
expect(container.querySelector('.rc-select-content-has-value')).toBeTruthy();
}); |
||
|
|
||
| it('should default select the right option', () => { | ||
| const { container } = render( | ||
| <Select defaultValue="2"> | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
目前的条件
displayValue && displayValue.label会错误地将0视为假值,这意味着当Select的值为0时,.rc-select-content-has-value这个 class 不会被应用,可能导致样式不正确。一个更完善的条件应该能确保
0被视为有效标签,同时正确处理空字符串的情况。