-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Wrong type ValidateProps.error / QFieldProps.error #16560
Comments
Fix will be available in Quasar v2.13.1. This is a special case where indeed we need a way to determine if the prop was set by the user or not. We use |
What happened?
The
error
prop of ValidateProps is defined inuse-validate.js
asboolean | null
:https://github.com/quasarframework/quasar/blob/dev/ui/src/composables/private/use-validate.js#L13-L16
However in the corresponding definitions file it is defined only as
boolean
:https://github.com/quasarframework/quasar/blob/dev/ui/src/composables/private/use-validate.json#L9-L13
This is especially a problem, as
null
is used inuseField
to hide or show the bottom container:https://github.com/quasarframework/quasar/blob/dev/ui/src/composables/private/use-field.js#L179-L185C1
This prevents us from hiding the bottom container when using the error prop in Typescript.
What did you expect to happen?
The type definition for the
error
prop should be corrected.Additionally, I would suggest, not using a
boolean | null
prop and then checking thenull
value. Vue automatically setsfalse
as default value forboolean
props if no default is given. Therefore, when writing a wrapper component for a QField component (which IMO is a common use case), I have to carefully check for which boolean prop I have to define a default value.Especially, when using the lastest feature of defining props with Typescript interfaces:
Without a
withDefaults
that sets theerror
prop tonull
, the bottom container will always be visible which is clearly not intended.Another example where this kind of wrapping a component leads to unexpected behavior is when the component uses the
dark
prop. Again, as default vue will set the prop tofalse
which leads to the component being rendered in thelight
theme regardless of the globally configured theme.Reproduction URL
https://stackblitz.com/edit/quasarframework-zqjz5g?file=README.md
How to reproduce?
It would be very helpful if you could add a forkable project with typescript to the issue template!
Flavour
Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)
Areas
Components (quasar), TypeScript Support
Platforms/Browsers
No response
Quasar info output
No response
Relevant log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: