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
|
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 {
|
override componentDidUpdate(_prevProps: NoteViewProps, prevState: State): void {
|
||||||
@@ -956,7 +948,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
|||||||
<PlainEditor
|
<PlainEditor
|
||||||
application={this.application}
|
application={this.application}
|
||||||
spellcheck={this.state.spellcheck}
|
spellcheck={this.state.spellcheck}
|
||||||
ref={(ref) => this.setPlainEditorRef(ref || undefined)}
|
ref={this.setPlainEditorRef}
|
||||||
controller={this.controller}
|
controller={this.controller}
|
||||||
locked={this.state.noteLocked}
|
locked={this.state.noteLocked}
|
||||||
onFocus={this.onPlainFocus}
|
onFocus={this.onPlainFocus}
|
||||||
|
|||||||
@@ -132,9 +132,15 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (controller.isTemplateNote && controller.templateNoteOptions?.autofocusBehavior === 'editor') {
|
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])
|
}, [controller, focusEditor])
|
||||||
|
|
||||||
@@ -155,6 +161,10 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
|
|||||||
}, [reloadPreferences, application])
|
}, [reloadPreferences, application])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (previousSpellcheck === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (spellcheck !== previousSpellcheck) {
|
if (spellcheck !== previousSpellcheck) {
|
||||||
setTextareaUnloading(true)
|
setTextareaUnloading(true)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user