Devographics / Monorepo

Monorepo containing the State of JS apps
surveyform-sigma.vercel.app
Other
127 stars 52 forks source link

Pain point text inputs unresponsive #315

Closed LostKobrakai closed 1 year ago

LostKobrakai commented 1 year ago

I have a hard time filling the pain point text inputs because it seems to regularly swallow keyboard input.

FF Developer Edition 118.0b9 on Mac OS

eric-burel commented 1 year ago

Can repro on FF 117 but not on Chrome, sorry about that Will investigate

eric-burel commented 1 year ago

Will be slightly improved on next release

For unknow reason, Firefox is unforgiveful when a component rerenders too much, so I've slightly optimized the TextList to limit value update. However I still need to update after a short inactivity delay. It doesn't happen with Chrome though.

It still swallows a few keystrokes but much less now (will be up in a few minutes).

We have a more significant optimization effort ongoing on #313

WIll keep open until it's fixed for good @SachaG

eric-burel commented 1 year ago

I've refactored it a bit to use fully uncontrolled inputs, and memoize relevant callbacks It's tricky to handle because we need state to display the right number of inputs, but we don't want state for the input values as it causes too many rerenders and somehow firefox can't stand that (despite using a correct key)

New version seems better, it doesn't lose data anymore due to weird race conditions, is a bit shorter It relies on a lot of annoying useCallback though but it seems to do the job

It can't be controlled so updating the textlist from another component would probably not work (while most other inputs are controlled, so you can change their value from another value) but I think that's an ok tradeoff for now