-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add input event to InputNumber #506
Comments
In my customized component, I did something like that. <template lang="pug">
template(v-if="type === 'number'")
InputNumber(v-model="value" @blur="validate()")
</template>
<script>
import { nextTick } from 'vue'
export default {
setup (props) {
const validate = async () => {
if (props.type === 'number') {
await nextTick()
// value updated
console.log(value.value)
}
}
}
}
</script> Hope it helps. |
This has made the number input worthless in any of my projects. I always use the text input then deal with a bunch of string to formatted number conversions. This is the reason I usually tell folks, "Prime isn't built for professional forms, out of the box." Thought I'd check in and see if there is an update, but it sounds like some sort of very silly stubbornness is keeping this in y'alls blind spot. |
I seems like you guys are causing continuous confusion by breaking standard, fundamental Vue input and https://vuejs.org/guide/essentials/forms.html Having to bind an event listener should not be necessary. It simply means more overhead. You guys have an awesome UI library, but at least for me, this is could definitely be a reason to switch to another. Frankly, in my opinion, it is quite ridiculous that you guys found this normal for years, especially seeing the stubborn mentions to this issue and the respective complaints from other developers. |
The solution I found was to simply use the event and use the value: Here is a example of the event ($event) returned from @input. From what I see, Therefore, my solution was : |
I don't like spending hours on finding workarounds for the basic functionality that should have been working out of the box though. |
@MilenaMalysh This is great, do you know if there is a way to globally attach a handleFunction to the input event of the InputNumber component, so that there is no need to add it individually to every instance where InputNumber is used? |
You should also check whether the value is "-" before you refocus because in other case the validation will not come through and you will be unable to input negative values. function refocus(event: InputNumberInputEvent) {
if (event.value === '-')
return
const target = event.originalEvent.target as HTMLElement
target.blur()
target.focus()
}
|
Unfortunately that doesn't work while removing numbers using backspace on my android |
The input event parses the value in the current input field and returns it to model. The value that comes to the model is the value that is not validated. This event is called every time one presses a key.
In current behavior, the model is updated in three ways;
And the value that comes to the model is the value that is validated.
The text was updated successfully, but these errors were encountered: