Slate: undo: only works with `onMouseDown` and not `onClick`

Created on 1 Aug 2019  路  2Comments  路  Source: ianstormtaylor/slate

Summary

When using editor.undo(), it doesn't work properly when called through onClick. However, it works with onMouseDown.

I made a reproduction repo here

Any ideas why this is?

GIFs

With onClick

with onCLick

With onMouseDown

with mouse down

I also tried adding event.preventDefault, and it had the same behaviour.

Most helpful comment

onMouseDown is called before onClickand is the one that move the focus to the button therefore preventDefault on onClick doesn't really help as the focus is already taken by the button

All 2 comments

onMouseDown is called before onClickand is the one that move the focus to the button therefore preventDefault on onClick doesn't really help as the focus is already taken by the button

Thanks for the explanation, I'll close this 馃槃

Was this page helpful?
0 / 5 - 0 ratings