-
Notifications
You must be signed in to change notification settings - Fork 121
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
Fix FWBInput does not support v-model.number (#273) #327
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes involve an update to the Changes
Poem
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 (
|
✅ Deploy Preview for sensational-seahorse-8635f8 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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
🧹 Outside diff range and nitpick comments (2)
src/components/FwbInput/FwbInput.vue (2)
61-61
: LGTM! The change supports v-model.number as intended.The modification to allow
modelValue
to be of typestring | number
successfully addresses the PR objective of supportingv-model.number
. This change enhances the component's flexibility in handling both string and numeric inputs.Consider the following improvements:
- Update the default value in
withDefaults
to account for the new type:const props = withDefaults(defineProps<InputProps>(), { // ... - modelValue: '', + modelValue: '' as string | number, // ... })
- Add type checking or conversion when setting the value to ensure type safety:
const model = computed({ get: () => props.modelValue, set: (value: string | number) => { if (props.type === 'number') { emit('update:modelValue', typeof value === 'string' ? parseFloat(value) : value) } else { emit('update:modelValue', String(value)) } } })These changes will further improve the component's robustness and type safety.
Line range hint
1-94
: Consider enhancing type handling and updating documentationWhile the change successfully allows for both string and number types, there are a few additional enhancements that could improve the component's behavior and usability:
- Add a computed property to handle type conversion based on the
type
prop:const typedModel = computed({ get: () => props.modelValue, set: (value: string | number) => { if (props.type === 'number') { model.value = typeof value === 'string' ? parseFloat(value) : value } else { model.value = String(value) } } })Then, use
v-model="typedModel"
in the template instead ofv-model="model"
.
- Update the component's documentation to reflect the new support for numeric values. This should include:
- Mentioning that
v-model.number
is now supported.- Explaining how the component handles type conversion between string and number based on the
type
prop.Would you like me to draft the documentation updates for you?
How's the state of this PR? |
This pull request enhances the modelValue prop to accept not only
string
types but alsonumber
types. This improvement provides more flexibility in handling diverse data inputs for the component especially when usingv-model.number
modifier.Summary by CodeRabbit
FwbInput
component to accept both string and numeric inputs for improved flexibility.