Skip to content

Commit

Permalink
Note: remove asyncFocus, restore focus on create (#2770)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-james authored Jan 15, 2025
1 parent 13f92af commit 95f11b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { setCursorActionCreator as setCursor } from '../actions/setCursor'
import { setDescendantActionCreator as setDescendant } from '../actions/setDescendant'
import { setNoteFocusActionCreator as setNoteFocus } from '../actions/setNoteFocus'
import { toggleNoteActionCreator as toggleNote } from '../actions/toggleNote'
import { isTouch } from '../browser'
import asyncFocus from '../device/asyncFocus'
import { isSafari, isTouch } from '../browser'
import * as selection from '../device/selection'
import simplifyPath from '../selectors/simplifyPath'
import store from '../stores/app'
Expand Down Expand Up @@ -50,6 +49,9 @@ const Note = React.memo(({ path }: { path: Path }) => {
// cursor must be true if note is focused
if (hasFocus) {
selection.set(noteRef.current!, { end: true })
// deleting a note, then closing the keyboard, then creating a new note could result in lack of focus,
// perhaps related to iOS Safari's internal management of selection ranges and focus
if (isTouch && isSafari()) noteRef.current?.focus()
}
}, [hasFocus])

Expand All @@ -75,7 +77,6 @@ const Note = React.memo(({ path }: { path: Path }) => {
else if (e.key === 'Backspace' && !note) {
e.stopPropagation() // prevent delete thought
e.preventDefault()
asyncFocus()
dispatch(deleteAttribute({ path, value: '=note' }))
dispatch(setNoteFocus({ value: false }))
} else if (e.key === 'ArrowDown') {
Expand Down

0 comments on commit 95f11b7

Please sign in to comment.