Open Torvin opened 3 years ago
Update: was able to break it in Chrome as well by adding setTimeout
: https://codesandbox.io/s/slate-0-5x-forked-mq5sd?file=/src/App.tsx
Now when I click, the focus just gets lost until I click again. Sounds like related to https://github.com/ianstormtaylor/slate/issues/3634?
Description In Firefox caret position is lost if render happens right after onFocus.
Imagine you do something like
<Editable onFocus={() => setState(...)}
- this causes the caret to jump back to the last position Slate remembers instead of the position I just clicked on (which resulted in this focus event to happen)This seems to work fine in latest Chrome. Didn't test other browsers.
Recording
Sandbox https://codesandbox.io/s/slate-0-5x-forked-0lxy7?file=/src/App.tsx
Steps To reproduce the behavior:
Expectation Slate shouldn't reset caret position if re-render happens right after focus event
Environment
slate@0.66.5
,slate-react@0.66.4