fix: issue where plaintext editor autofocus would interfere with sign in form
This commit is contained in:
@@ -231,16 +231,8 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
}
|
||||
}
|
||||
|
||||
setPlainEditorRef = (ref: PlainEditorInterface | undefined) => {
|
||||
setPlainEditorRef = (ref: PlainEditorInterface | null) => {
|
||||
this.plainEditorRef = ref || undefined
|
||||
|
||||
if (!this.plainEditorRef) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.controller.isTemplateNote && this.controller.templateNoteOptions?.autofocusBehavior === 'editor') {
|
||||
this.plainEditorRef.focus()
|
||||
}
|
||||
}
|
||||
|
||||
override componentDidUpdate(_prevProps: NoteViewProps, prevState: State): void {
|
||||
@@ -956,7 +948,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
||||
<PlainEditor
|
||||
application={this.application}
|
||||
spellcheck={this.state.spellcheck}
|
||||
ref={(ref) => this.setPlainEditorRef(ref || undefined)}
|
||||
ref={this.setPlainEditorRef}
|
||||
controller={this.controller}
|
||||
locked={this.state.noteLocked}
|
||||
onFocus={this.onPlainFocus}
|
||||
|
||||
@@ -132,9 +132,15 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
|
||||
|
||||
useEffect(() => {
|
||||
if (controller.isTemplateNote && controller.templateNoteOptions?.autofocusBehavior === 'editor') {
|
||||
setTimeout(() => {
|
||||
focusEditor()
|
||||
})
|
||||
focusEditor()
|
||||
}
|
||||
}, [controller, focusEditor])
|
||||
|
||||
useEffect(() => {
|
||||
const shouldFocus = controller.isTemplateNote && controller.templateNoteOptions?.autofocusBehavior === 'editor'
|
||||
|
||||
if (shouldFocus) {
|
||||
focusEditor()
|
||||
}
|
||||
}, [controller, focusEditor])
|
||||
|
||||
@@ -155,6 +161,10 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
|
||||
}, [reloadPreferences, application])
|
||||
|
||||
useEffect(() => {
|
||||
if (previousSpellcheck === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
if (spellcheck !== previousSpellcheck) {
|
||||
setTextareaUnloading(true)
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user