mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-06 02:17:49 +08:00
fix losing text selection when using focus on Android (#4448)
This commit is contained in:
parent
425332eea9
commit
8b05853d9a
@ -1,7 +1,6 @@
|
|||||||
import { isTextSelection } from '../helpers/isTextSelection.js'
|
import { isTextSelection } from '../helpers/isTextSelection.js'
|
||||||
import { resolveFocusPosition } from '../helpers/resolveFocusPosition.js'
|
import { resolveFocusPosition } from '../helpers/resolveFocusPosition.js'
|
||||||
import { FocusPosition, RawCommands } from '../types.js'
|
import { FocusPosition, RawCommands } from '../types.js'
|
||||||
import { isiOS } from '../utilities/isiOS.js'
|
|
||||||
|
|
||||||
declare module '@tiptap/core' {
|
declare module '@tiptap/core' {
|
||||||
interface Commands<ReturnType> {
|
interface Commands<ReturnType> {
|
||||||
@ -43,11 +42,7 @@ export const focus: RawCommands['focus'] = (position = null, options = {}) => ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const delayedFocus = () => {
|
const delayedFocus = () => {
|
||||||
// focus within `requestAnimationFrame` breaks focus on iOS
|
(view.dom as HTMLElement).focus()
|
||||||
// so we have to call this
|
|
||||||
if (isiOS()) {
|
|
||||||
(view.dom as HTMLElement).focus()
|
|
||||||
}
|
|
||||||
|
|
||||||
// For React we have to focus asynchronously. Otherwise wild things happen.
|
// For React we have to focus asynchronously. Otherwise wild things happen.
|
||||||
// see: https://github.com/ueberdosis/tiptap/issues/1520
|
// see: https://github.com/ueberdosis/tiptap/issues/1520
|
||||||
|
Loading…
Reference in New Issue
Block a user