RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.39k stars 2.17k forks source link

Pressing 'Enter' on a textarea with regex types the word 'Enter' #2742

Open MattPurland opened 1 year ago

MattPurland commented 1 year ago
MattPurland commented 1 year ago

I've figured out a workaround using the onKeyDown event:

        onKeyDown: (e) => {
            if(e.which == 13) {
                e.target.value = e.target.value + "\r";
                return false;
            }
        }
RobinHerbots commented 1 year ago

Hi @MattPurland,

This is already fixed in the 5.0.9-beta version.

MattPurland commented 1 year ago

Sorry, it looks like this still isn't working (I'm testing with 5.0.9-beta.32). Please see updated codepen

MattPurland commented 1 year ago

Updated workaround for those interested

            if(e.which == 13) {
                let value = e.target.value,
                    index = e.target.selectionStart;

                e.target.value = value.slice(0, index) + "\r" + value.slice(index);
                e.target.setSelectionRange(index + 1, index + 1);

                return false;
            }