Hacker News new | past | comments | ask | show | jobs | submit login

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/ind...




Your 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.


IIRC 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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: