GoncharukOrg / react-input

100 stars 7 forks source link

Can't use masking with any other fields than type 'text'. #20

Closed luketurner-casumo closed 5 months ago

luketurner-casumo commented 7 months ago

Hi I am looking to integrate your masking library into our codebase. However I have run into an issue where your checks are too strict and require inputElement.type === 'text'. validInputCheck Would it be possible to expand the scope of this check to allow for other input element types such as search etc? I see no reason why this check needs to be so strict 🤔 Is this something that can be resolved?

luketurner-casumo commented 7 months ago

Updating the code to something like this should do the job 😄

const validInputElements = ['text', 'search', 'tel', 'url', 'email', 'password'];

const validInputElement = (inputElement: HTMLInputElement | null) =>
  inputElement !== null && validInputElements.includes(inputElement.type);
luketurner-casumo commented 7 months ago

https://github.com/GoncharukBro/react-input/assets/106586112/b0d79a98-388d-4920-88ae-c61d2f9d4026

Just to test my theory I have locally removed these checks and everything works perfectly with input type search 😄

GoncharukBro commented 7 months ago

Thanks for the suggestion, we are considering the possibility of supporting other types for consistency with libraries that require this. We will include this fix in the next release.

luketurner-casumo commented 7 months ago

Thanks for the suggestion, we are considering the possibility of supporting other types for consistency with libraries that require this. We will include this fix in the next release.

Brilliant thank you! Do you possibly have an idea when this next release will drop?

GoncharukBro commented 6 months ago

Hello, install the new version:

npm i @react-input/mask@latest

It includes support for the following types: “text”, “email”, “phone”, “search”, “url”. The "password" type is not included because by masking every character in the value, including mask characters, this type of input can be confusing to users.