Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: fix flicker when typing in multiline title

Abdullah Attab4366058dda6
diff --git a/apps/web/src/components/editor/title-box.tsx b/apps/web/src/components/editor/title-box.tsx
index 896c7f9c0..4fe47e2d9 100644
--- a/apps/web/src/components/editor/title-box.tsx
+++ b/apps/web/src/components/editor/title-box.tsx
@@ -62,7 +62,7 @@ function TitleBox(props: TitleBoxProps) {
withSelectionPersist(inputRef.current, (input) => {
input.value = title || "";
- resizeTextarea(input);
+ requestAnimationFrame(() => resizeTextarea(input));
});
}, [sessionType, id, sessionTitle]);
@@ -155,11 +155,9 @@ export default React.memo(TitleBox, (prevProps, nextProps) => {
});
function resizeTextarea(input: HTMLTextAreaElement) {
+ input.style.height = "auto";
requestAnimationFrame(() => {
- input.style.height = "auto";
- requestAnimationFrame(() => {
- input.style.height = input.scrollHeight + "px";
- });
+ input.style.height = input.scrollHeight + "px";
});
}