Add noSpaceBetweenChars option
@sanniassin Here is my first pass at this. I tried to get Mocha set up for writing fast unit tests, but I was beating my head against getting import statements to work in the Mocha tests. I didn't really want to mess with your babel-env too much, but I think it would be good to be able to easily unit test src/utils, since they tend to do some important lifting.
Closes #155
@dbalatero Thank you. I'll take a close look in a few days. Sorry for the delay.
@dbalatero Since the idea is to mimic the regular input behavior, there are a couple more things need to be adjusted:
- Cursor shouldn't be allowed to move after the first empty position
- Typing over existing character should insert the typed character before the existing one, not replace it
So these two inputs should behave almost identically. The only difference is that in the second case input value will always contain six characters with spaces in place of the empty ones.
<InputMask mask="999999" maskChar={null} />
<InputMask mask="999999" maskChar=" " noSpaceBetweenChars />
Since the idea is to mimic the regular input behavior, there are a couple more things need to be adjusted
@sanniassin Sounds good, I will get to these as well.
Typing over existing character should insert the typed character before the existing one, not replace it
You know, I thought this should be the behavior also, but I thought I saw other examples of the character replacing what was there. Weird, I'll try to repro it and see if that is still an issue, or maybe I had some code in there that was messing everything up.
@sanniassin
Cursor shouldn't be allowed to move after the first empty position
Addressed in db12076
Typing over existing character should insert the typed character before the existing one, not replace it
Before I do anything on this, I wanted to check in first. I'm seeing this very same behavior on master, which implies to me that we might want to open a separate PR for this issue and get this one closed out? It doesn't seem like the changes I'm making here are creating the issue, since master is exhibiting the same behavior. Can you maybe double-check this for me, as maybe I'm having build caching issues between branches?
Thanks!
Before I do anything on this, I wanted to check in first. I'm seeing this very same behavior on master, which implies to me that we might want to open a separate PR for this issue and get this one closed out?
Sorry, I don't get it. There are two behaviors in master. The first one replaces existing characters and it's intended for cases when maskChar isn't empty or input is filled and there is no free space left. The second one inserts new characters and keeps the existing ones. It's intended for cases with empty maskChar when input has some free space.
I propose to use the second one for noSpaceBetweenChars.
Is there something wrong with this mechanics?
Is there something wrong with this mechanics?
Not at all, I think it just wasn't clear to me that there were two behaviors. Now that I know, I'll go with the second one, thanks!
I'll address these PR comments as well!
@dbalatero Do you have any updates on this? I have come across a similar issue using this library and it would be great to have this an option in react-input-mask.
@dreamthink hey sorry to say I've abandoned this work as it got de-prioritized at work and we just ended up living with it. I probably won't pick this back up at this point so if @sanniassin wants to close it that's fine with me.
@dreamthink hey sorry to say I've abandoned this work as it got de-prioritized at work and we just ended up living with it. I probably won't pick this back up at this point so if @sanniassin wants to close it that's fine with me.
@dbalatero Is there a follow up on this?
Nope, sorry. I can't work on this; I don't use the library anymore and I won't be able to find any time to do it. Best of luck - if you want to use this PR as a starting point please do…