quasar icon indicating copy to clipboard operation
quasar copied to clipboard

Cannot enter the fourth zero with mask '#:0:0:###'

Open doox911 opened this issue 10 months ago • 8 comments

What happened?

The fourth zero disappears

What did you expect to happen?

0:0:0:0 in the q-input as a value

Reproduction URL

https://codepen.io/doox911/pen/PwwzGgr?editors=101

How to reproduce?

  1. Enter zero
  2. Enter zero

Flavour

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

Areas

SPA Mode

Platforms/Browsers

Other

Quasar info output


Relevant log output


Additional context

No response

doox911 avatar Apr 22 '25 08:04 doox911

Problem is more complex. The reason is the suppression of input characters from mask. With mask="1###" you can't enter number with 1

FragsterAt avatar Apr 22 '25 12:04 FragsterAt

Numbers are not supported tokens in the mask: https://quasar.dev/vue-components/input#mask .

You probably want to have some regex based manual validation.

stefanvanherwijnen avatar May 06 '25 14:05 stefanvanherwijnen

Numbers are not supported tokens in the mask: https://quasar.dev/vue-components/input#mask .

You probably want to have some regex based manual validation.

The documentation specifically states that it is supported. The '#' symbol is used.

https://github.com/quasarframework/quasar/blob/dev/ui/src/components/input/use-mask.js#L6

doox911 avatar May 06 '25 14:05 doox911

Numbers are not supported tokens in the mask: https://quasar.dev/vue-components/input#mask . You probably want to have some regex based manual validation.

The documentation specifically states that it is supported. The '#' symbol is used.

https://github.com/quasarframework/quasar/blob/dev/ui/src/components/input/use-mask.js#L6

I mean numbers like '0', '1', '2' etc. ### works fine, 1## does not.

stefanvanherwijnen avatar May 06 '25 14:05 stefanvanherwijnen

Numbers are not supported tokens in the mask: https://quasar.dev/vue-components/input#mask . You probably want to have some regex based manual validation.

The documentation specifically states that it is supported. The '#' symbol is used. https://github.com/quasarframework/quasar/blob/dev/ui/src/components/input/use-mask.js#L6

I mean numbers like '0', '1', '2' etc. ### works fine, 1## does not.

I don't quite understand you. In my case, it's not 1##, but rather 1:##. Could you please elaborate in more detail on what you mean?

doox911 avatar May 06 '25 14:05 doox911

It does work a little different than I thought. You can only use the input with the supported mask tokens

With 1:## you can only enter two numeric characters. With 1:0:0:0 you can't enter anything as there are no mask tokens.

stefanvanherwijnen avatar May 06 '25 15:05 stefanvanherwijnen

It does work a little different than I thought. You can only use the input with the supported mask tokens

With 1:## you can only enter two numeric characters. With 1:0:0:0 you can't enter anything as there are no mask tokens.

Well, that's clear enough! My problem is that with the mask 0:#, I can't input 0 in place of the # symbol.

doox911 avatar May 06 '25 15:05 doox911

@doox911 I had a look at this. This is caused because of this line in use-mask.js.

I believe in this case the comparison here is wrong.

if (typeof maskDef === 'string') {
  output += maskDef
  valChar === maskDef && valIndex++
}

It wrongly consumes the input value (i.e. increments valIndex) just because the literal happens to match the next typed char (like '0').

Maybe this is done willingly for other more complex/predefined cases. Otherwise it's a bug and this line can safely be removed. This line too I suppose for the reverse mask.

Dtsiantaris avatar May 10 '25 15:05 Dtsiantaris