s-yadav / react-number-format

React component to format numbers in an input or as a text.
MIT License
3.88k stars 409 forks source link

Rerender component after change value and lost focus #782

Open Dobroeutro1 opened 1 year ago

Dobroeutro1 commented 1 year ago

Describe the issue and the actual behavior

Hello. I faced such problem. After entering the value in the input, my focus disappears. As a result of debugging, I found that the reason is the re-rendering of the input component after entering one character. Could you tell me what is the reason for this behavior.

I also noticed that this behavior appears if you build the project in webpack production mode. There is no such problem in development mode.

Describe the expected behavior

I expect focus to be saved when entering a value in an input

Provide steps to reproduce this issue

image image image

Please check the browsers where the issue is seen

s-yadav commented 1 year ago

I suspect some additional thing is happening on your parent component. most likely you are breaking rule of reconciliation, can't say to confirm with the provided code.

Dobroeutro1 commented 1 year ago

Nothing else happens in my parent component. It simply renders the PatternFormat, sets up the state, and handles the state change.

s-yadav commented 1 year ago

It would be easy for me to tell the reason if you can provide some repro link.

Also, can you tell which version are you using?

hemantgogia09 commented 8 months ago

Same thing is happening with me only in webpack production. I am using 5.3.1.

YuriiLutsykSPRO commented 3 months ago

I faced the same problem with a customInput, please memoize your custom input