Skip to content

Commit

Permalink
fix losing text selection when using focus on Android (#4448)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellovietduc authored Nov 30, 2024
1 parent 425332e commit 8b05853
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions packages/core/src/commands/focus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { isTextSelection } from '../helpers/isTextSelection.js'
import { resolveFocusPosition } from '../helpers/resolveFocusPosition.js'
import { FocusPosition, RawCommands } from '../types.js'
import { isiOS } from '../utilities/isiOS.js'

declare module '@tiptap/core' {
interface Commands<ReturnType> {
Expand Down Expand Up @@ -43,11 +42,7 @@ export const focus: RawCommands['focus'] = (position = null, options = {}) => ({
}

const delayedFocus = () => {
// focus within `requestAnimationFrame` breaks focus on iOS
// so we have to call this
if (isiOS()) {
(view.dom as HTMLElement).focus()
}
(view.dom as HTMLElement).focus()

// For React we have to focus asynchronously. Otherwise wild things happen.
// see: https://github.com/ueberdosis/tiptap/issues/1520
Expand Down

0 comments on commit 8b05853

Please sign in to comment.