Skip to content
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

Allow keypress to replace/overwrite character of completed mask #129

Closed
jgelo opened this issue Dec 2, 2018 · 9 comments
Closed

Allow keypress to replace/overwrite character of completed mask #129

jgelo opened this issue Dec 2, 2018 · 9 comments

Comments

@jgelo
Copy link

jgelo commented Dec 2, 2018

I've got a simple date mask setup using the following -

new IMask(input, {
  lazy:   false,
  mask:   'yyyy-mm-dd',
  blocks: {
    dd:   {mask: IMask.MaskedRange, placeholderChar: 'd', from: 1, to: 31, maxLength: 2},
    mm:   {mask: IMask.MaskedRange, placeholderChar: 'm', from: 1, to: 12, maxLength: 2},
    yyyy: {mask: IMask.MaskedRange, placeholderChar: 'y', from: 1900, to: 2999, maxLength: 4}
  }
});

Once the input contains a complete mask (such as 2018-12-02), it's not possible to replace/overwite an existing digit without first deleting it.

Is there a way to allow valid characters to replace an existing character at the cursor position on keypress when the input already contains a complete mask?

@uNmAnNeR
Copy link
Owner

uNmAnNeR commented Dec 5, 2018

Currently no, and i don't have plans to implement it. But it's reasonable to have, so may be later i will be able to do it. Let's don't close it for a while.

@jgelo
Copy link
Author

jgelo commented Dec 5, 2018

I imagine it would be a beneficial feature for a number of users, thanks for your consideration!

If I get some time to dig into it, I'll see if I can provide a pull request.

@uNmAnNeR
Copy link
Owner

uNmAnNeR commented Dec 5, 2018

@jgelo it would be great

@uNmAnNeR
Copy link
Owner

uNmAnNeR commented Jan 1, 2019

@jgelo Hi!
Some questions about replace behavior:

  1. should it replace chars only if it's not possible to shift or anyway (just like in insert mode)?
  2. another way what cleavejs does is not to overwrite but to shift tail.

What do you think? How should it work and why?

@jgelo
Copy link
Author

jgelo commented Jan 2, 2019

@jgelo Hi!
Some questions about replace behavior:

  1. should it replace chars only if it's not possible to shift or anyway (just like in insert mode)?
  2. another way what cleavejs does is not to overwrite but to shift tail.

What do you think? How should it work and why?

@uNmAnNeR, I'm on winter holiday so haven't had a chance to look at the code yet. I've attached a quick demo of a custom jquery date and account number widget that I'm trying to replicate in vanillajs. The default input for these widgets is to simply overwrite the character at the cursor position (if valid). Pressing backspace or delete exposes the underlying mask character.

mask_input

@uNmAnNeR uNmAnNeR added this to the v5.0.0 milestone Apr 17, 2019
@uNmAnNeR
Copy link
Owner

@jgelo can you please check PR #167 :)

@uNmAnNeR
Copy link
Owner

done in v5.0.0

@jgelo
Copy link
Author

jgelo commented Apr 22, 2019

@jgelo can you please check PR #167 :)

Just installed v5.0.0 to check the new 'overwrite' flag, works perfectly, many thanks!

@uNmAnNeR
Copy link
Owner

@jgelo consider v5.1.0. I think there might be interesting feature for you.

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

No branches or pull requests

2 participants