mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-13 05:11:04 +08:00
fix(core): resolve focus regression (#6043)
This commit is contained in:
parent
a44a7c38b5
commit
fa63c47919
5
.changeset/thirty-deers-attend.md
Normal file
5
.changeset/thirty-deers-attend.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@tiptap/core": patch
|
||||
---
|
||||
|
||||
Focus synchronously only if on iOS or Android #4448
|
@ -1,6 +1,8 @@
|
||||
import { isTextSelection } from '../helpers/isTextSelection.js'
|
||||
import { resolveFocusPosition } from '../helpers/resolveFocusPosition.js'
|
||||
import { FocusPosition, RawCommands } from '../types.js'
|
||||
import { isAndroid } from '../utilities/isAndroid.js'
|
||||
import { isiOS } from '../utilities/isiOS.js'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands<ReturnType> {
|
||||
@ -42,7 +44,11 @@ export const focus: RawCommands['focus'] = (position = null, options = {}) => ({
|
||||
}
|
||||
|
||||
const delayedFocus = () => {
|
||||
(view.dom as HTMLElement).focus()
|
||||
// focus within `requestAnimationFrame` breaks focus on iOS and Android
|
||||
// so we have to call this
|
||||
if (isiOS() || isAndroid()) {
|
||||
(view.dom as HTMLElement).focus()
|
||||
}
|
||||
|
||||
// For React we have to focus asynchronously. Otherwise wild things happen.
|
||||
// see: https://github.com/ueberdosis/tiptap/issues/1520
|
||||
|
Loading…
Reference in New Issue
Block a user