3 ms·
it is possible to track and set cursor location after updating innerHTML... it is definitely no longer simple and clean though haha. https://codesandbox.io/s/z
by ericmcer 6y ago
it is possible to track and set cursor location after updating innerHTML... it is definitely no longer simple and clean though haha.
https://codesandbox.io/s/zealous-vaughan-qd3gg?file=/src/index.js https://codesandbox.io/s/zealous-vaughan-qd3gg?file=/src/ind...
- eliseumds 6y agoYour answered yourself there. It's not only about input focus, it could be anything really, like loading state, form values, progress indicator, etc. People will be basically building yet another framework at the end. React is not the only solution, there are plenty of lighter alternatives. OP's solution is just very type-unsafe.
- SahAssar 6y agoIIRC it will also lead to weird behavior for people using screenreaders, they usually restart saying whatever they where reading when the element was replaced even if the contents are the same.