diff --git a/.changeset/gold-bottles-collect.md b/.changeset/gold-bottles-collect.md new file mode 100644 index 0000000000..9f424914ff --- /dev/null +++ b/.changeset/gold-bottles-collect.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Apply 300ms placeholder delay only on Android devices diff --git a/packages/slate-react/src/components/leaf.tsx b/packages/slate-react/src/components/leaf.tsx index 7ac2a43fb5..0bef06537c 100644 --- a/packages/slate-react/src/components/leaf.tsx +++ b/packages/slate-react/src/components/leaf.tsx @@ -16,7 +16,11 @@ import { } from '../utils/weak-maps' import { RenderLeafProps, RenderPlaceholderProps } from './editable' import { useSlateStatic } from '../hooks/use-slate-static' -import { IS_WEBKIT } from '../utils/environment' +import { IS_WEBKIT, IS_ANDROID } from '../utils/environment' + +// Delay the placeholder on Android to prevent the keyboard from closing. +// (https://github.com/ianstormtaylor/slate/pull/5368) +const PLACEHOLDER_DELAY = IS_ANDROID ? 300 : 0 function disconnectPlaceholderResizeObserver( placeholderResizeObserver: MutableRefObject, @@ -104,7 +108,7 @@ const Leaf = (props: { showPlaceholderTimeoutRef.current = setTimeout(() => { setShowPlaceholder(true) showPlaceholderTimeoutRef.current = null - }, 300) + }, PLACEHOLDER_DELAY) } } else { clearTimeoutRef(showPlaceholderTimeoutRef)