1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-23 23:42:56 +02:00

Apply placeholder delay only on Android devices (#5564)

This commit is contained in:
Joe Anderson
2023-11-22 13:22:40 +00:00
committed by GitHub
parent 9db2bd2c9b
commit 9aa573e9b8
2 changed files with 11 additions and 2 deletions

View File

@@ -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<ResizeObserver | null>,
@@ -104,7 +108,7 @@ const Leaf = (props: {
showPlaceholderTimeoutRef.current = setTimeout(() => {
setShowPlaceholder(true)
showPlaceholderTimeoutRef.current = null
}, 300)
}, PLACEHOLDER_DELAY)
}
} else {
clearTimeoutRef(showPlaceholderTimeoutRef)