fix(InputMenu/Select/SelectMenu): exclude cosmetic items from model value type#6044
Conversation
…scing assignment, following other components
… both nullish and optional are present
📝 WalkthroughWalkthroughThis pull request updates type handling and narrow-cases across input and select components and shared types. Components (Input.vue, Textarea.vue) tighten when modelModifiers.optional can coerce values to undefined by requiring nullable to be false and the current value non-null. Menu/select components (InputMenu.vue, Select.vue, SelectMenu.vue) introduce an internal ExcludeItem type and thread it through props, emits, slots, and helper typings to exclude label/separator item shapes from model values. Utility types in utils.ts are refactored to add an optional O parameter propagated through GetItemValue, GetModelValue, and GetModelValueEmits. input.ts adjusts ModelModifiers conditional defaults. Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/runtime/components/SelectMenu.vue (1)
37-38: Naming inconsistency:ExcludeMenuItemhere vsExcludeItemin Select.vue.Select.vue defines
type ExcludeItem = { type: 'label' | 'separator' }while SelectMenu.vue and InputMenu.vue useExcludeMenuItem. Since these are file-local types with identical shapes, this isn't a bug, but unifying the name (e.g., allExcludeItem) would reduce cognitive overhead when navigating between components.
commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/runtime/components/SelectMenu.vue (1)
37-37: ExtractExcludeItemto shared types.This type is identically defined in
Select.vue,SelectMenu.vue, andInputMenu.vue. Move it tosrc/runtime/types/utils.tswhere the components already import shared generics likeGetItemValueandGetModelValue, eliminating duplication and establishing a single source of truth.
Some components like
InputMenu,SelectMenuandSelectsupport for items that are purely cosmetic liketype: 'label'andtype: 'separator'.This causes a waterfall of type issues