chore: memoize plain editor ref function

This commit is contained in:
Aman Harwara
2024-01-11 19:39:07 +05:30
parent 7bafde5be7
commit 3d895ca499

View File

@@ -205,7 +205,8 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
} }
}, [spellcheck, previousSpellcheck]) }, [spellcheck, previousSpellcheck])
const onRef = (ref: HTMLTextAreaElement | null) => { const onRef = useCallback(
(ref: HTMLTextAreaElement | null) => {
if (tabObserverDisposer.current || !ref) { if (tabObserverDisposer.current || !ref) {
return return
} }
@@ -269,7 +270,9 @@ export const PlainEditor = forwardRef<PlainEditorInterface, Props>(
observer.observe(editor.parentElement as HTMLElement, { childList: true }) observer.observe(editor.parentElement as HTMLElement, { childList: true })
mutationObserver.current = observer mutationObserver.current = observer
} },
[application.keyboardService, controller],
)
if (textareaUnloading) { if (textareaUnloading) {
return null return null