Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

QInput's rules prop has bug #17734

Open
kwarnkham opened this issue Jan 7, 2025 · 2 comments
Open

QInput's rules prop has bug #17734

kwarnkham opened this issue Jan 7, 2025 · 2 comments

Comments

@kwarnkham
Copy link
Contributor

Description

This is how I use rules

:rules="[
              ruleNotEmpty,
              (val) =>
                removeCommaFromNumber(val) <= 10000 ||
                'The amount is higher than the tender amount',
              ruleGreaterThanZero,
            ]"

These are the rules

  const ruleNotEmpty = (val) => val !== '' || 'Cannot be empty';
  const ruleGreaterThanZero = (val) => removeCommaFromNumber(val) > 0 || 'Minimum value is 1'

When I try to trigger the validation errors, sometimes I get the following error.

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'focus')
  at quasar_dist_quasar__client__js.js?v=5ff75e9a:15063:79
  at Array.find (<anonymous>)
  at quasar_dist_quasar__client__js.js?v=5ff75e9a:15063:40

When I follow the link in error

if (focus2 === true) {
          const activeError = errors.find(({ comp: comp2 }) => typeof comp2.focus === "function" && vmIsDestroyed(comp2.$) === false);
          if (activeError !== void 0) {
            activeError.comp.focus();
          }
        }

Documentation Section URL

https://quasar.dev/vue-components/input#qinput-api

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Components (quasar)

@rstoenescu
Copy link
Member

The details actually matter.
Please try to create a codepen or stackblitz to highlight the problem.

@rstoenescu rstoenescu added the bug/0-needs-info Need more info to reproduce label Jan 14, 2025
@rstoenescu
Copy link
Member

Also make sure that your validation rule functions do not crash!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants