We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7557adc commit 96538b6Copy full SHA for 96538b6
packages/slate-react/src/components/slate.tsx
@@ -72,6 +72,9 @@ export const Slate = (props: {
72
useIsomorphicLayoutEffect(() => {
73
const fn = () => setIsFocused(ReactEditor.isFocused(editor))
74
if (IS_REACT_VERSION_17_OR_ABOVE) {
75
+ // In React >= 17 onFocus and onBlur listen to the focusin and focusout events during the bubbling phase.
76
+ // Therefore in order for <Editable />'s handlers to run first, which is necessary for ReactEditor.isFocused(editor)
77
+ // to return the correct value, we have to listen to the focusin and focusout events without useCapture here.
78
document.addEventListener('focusin', fn)
79
document.addEventListener('focusout', fn)
80
return () => {
0 commit comments