Skip to content

Commit

Permalink
Apply placeholder delay only on Android devices (#5564)
Browse files Browse the repository at this point in the history
  • Loading branch information
12joan authored Nov 22, 2023
1 parent 9db2bd2 commit 9aa573e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-bottles-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate-react': patch
---

Apply 300ms placeholder delay only on Android devices
8 changes: 6 additions & 2 deletions packages/slate-react/src/components/leaf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -104,7 +108,7 @@ const Leaf = (props: {
showPlaceholderTimeoutRef.current = setTimeout(() => {
setShowPlaceholder(true)
showPlaceholderTimeoutRef.current = null
}, 300)
}, PLACEHOLDER_DELAY)
}
} else {
clearTimeoutRef(showPlaceholderTimeoutRef)
Expand Down

0 comments on commit 9aa573e

Please sign in to comment.