-
Notifications
You must be signed in to change notification settings - Fork 309
fix(color-picker): [color-picker] fix color-picker props valid error #2841
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
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
WalkthroughThis pull request addresses a validation error in the Changes
|
@@ -20,7 +20,7 @@ export default defineComponent({ | |||
type: String, | |||
default: '', | |||
validator(val: string) { | |||
return [' large', 'medium', 'small', 'mini', ''].includes(val) | |||
return ['large', 'medium', 'small', 'mini', ''].includes(val) |
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.
Fixed a critical issue in the validator function by removing an unintended space from the valid values array, ensuring proper validation of the size
prop.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/vue/src/color-picker/src/index.ts (1)
Line range hint
16-24
: Consider enhancing the size prop implementation.While the fix addresses the immediate issue, consider these improvements for better maintainability:
- Extract the size values into a constant for reuse
- Add JSDoc comments documenting the valid sizes
- Consider adding a warning for 'mini' if it's deprecated
Here's a suggested implementation:
+ const VALID_SIZES = ['large', 'medium', 'small', 'mini', ''] as const; + type ColorPickerSize = typeof VALID_SIZES[number]; size: { type: String, default: '', + /** + * Size of the color picker + * @values 'large' | 'medium' | 'small' | 'mini' | '' + */ validator(val: string) { - return ['large', 'medium', 'small', 'mini', ''].includes(val) + const isValid = VALID_SIZES.includes(val as ColorPickerSize); + if (val === 'mini') { + console.warn('The "mini" size might be deprecated in future versions'); + } + return isValid; } },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/vue/src/color-picker/src/index.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (1)
packages/vue/src/color-picker/src/index.ts (1)
23-23
: LGTM! Bug fix correctly removes the unintended space.The validation array now properly validates the size values without the leading space issue.
PR
修复clolor-picker组件props类型判断报错
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit