Skip to content

Bug with input type=number with maska/vue #276

@rodsscg

Description

@rodsscg

Describe the bug

If a input with type="number" has the v-mask directive, even if we not pass any mask, the input does not accept typing a .. The directive should not be enabled if an incompatible type is used, like the number.

Steps to reproduce

  • Create a input with type=number and v-mask="null"
  • Type a number, then .. Like: 16.. The . will not be rendered.

Suggestion

The documentation of maska tells the types that are compatible, but the directive only checks if the type is not a file type. The correct solution would be to only enable with the compatible types.

const allowedTypes = ['text', 'search', 'url', 'tel', 'password'];
const input = el instanceof HTMLInputElement ? el : el.querySelector('input');

 if (input == null || !allowedTypes.includes(input.type)) return;

List of compatible types on the documentation: https://beholdr.github.io/maska/v3/#/issues?id=unsupported-input-types

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions