imaskjs icon indicating copy to clipboard operation
imaskjs copied to clipboard

useIMask doesn't add event listener accept & complete on some cases

Open baran-ozer opened this issue 1 year ago • 0 comments

Describe the bug When I render my dom elements optionally I have deteced that useIMask hook can't add event listener to my input.

To Reproduce You can see this error on reactplayground. IMask on input works correctly but it doesn't update IMask value since there is no accept and complete event on my input. When dom loads IMask https://github.com/uNmAnNeR/imaskjs/blob/d1fe83e20addb1dc217f2c126e4e2b78aaf1c6be/packages/react-imask/src/hook.ts#L142-L154 this hook above triggers once but imask.ref is empty so it can't attach event listeners, then on second render(when isLoading state setted to false on my playground code) this hook never triggers again.

Expected behavior A clear and concise description of what you expected to happen.

Environment:

  • OS: [macOS]
  • Browser: [chrome]
  • Version: [128.0.6613.138]
  • IMask version: [7.6.1]
  • Framework/plugin version : [React 18.2.0]

Additional context I have fixed this issue by updating this dependency hook: https://github.com/uNmAnNeR/imaskjs/blob/d1fe83e20addb1dc217f2c126e4e2b78aaf1c6be/packages/react-imask/src/hook.ts#L142-L154 I can open a PR for this if you agree that this is a bug.

baran-ozer avatar Sep 20 '24 07:09 baran-ozer