QInput unexpectedly always displays bottom area for error message when rules property is used #17722
Unanswered
suniga-mrs
asked this question in
General - Components / Directives / etc
Replies: 1 comment
-
Any help or insight here would be great |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! I'm new to the quasar ecosystem and just playing around with the form components for a while
Currently I am using QInput's rules property to make validation easier.
<q-input filled v-model="lastName" label="Last name *" lazy-rules :rules="[val => val && val.length > 0 || 'Please type something']" />
Unexpectedly, I've come across this behaviour. The bottom div is always displayed despite it being in the initial (or reset state). Meaning no error message should be displayed. See below examples (Note: I've added a background color to make a point here)
What I expected was:
I wanted to conserve screen space as much as possible and not have dead space in between form fields.
Browsing through the source code, I might have found the culprit here
https://github.com/quasarframework/quasar/blob/dev/ui/src/composables/private.use-field/use-field.js#L189
Proposed change:
Would it make sense to replace this line with something like this:
hasError.value == true && (errorMessage.value != null || errorMessage.value.length != 0)
Any idea what could be the implication of this change? I would very much prefer to use the rules and not rely on another package for validation.
Beta Was this translation helpful? Give feedback.
All reactions