Skip to content

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

web: fix incorrect title on scrolling note (#4137)

theProtona47a38b16b2e
diff --git a/apps/web/src/components/editor/toolbar.jsx b/apps/web/src/components/editor/toolbar.jsx
index b0ca17c33..2bb5b4329 100644
--- a/apps/web/src/components/editor/toolbar.jsx
+++ b/apps/web/src/components/editor/toolbar.jsx
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useMemo, useRef, useState } from "react";
import { Button, Flex, Text } from "@theme-ui/components";
import {
Published,
@@ -63,6 +63,7 @@ function Toolbar() {
const theme = useThemeStore((store) => store.colorScheme);
const toggleNightMode = useThemeStore((store) => store.toggleColorScheme);
const [isTitleVisible, setIsTitleVisible] = useState(false);
+ const onScrollTitleRef = useRef(null);
const monographs = useMonographStore((store) => store.monographs);
const { canRedo, canUndo, redo, undo } = useHistory();
@@ -92,6 +93,11 @@ function Toolbar() {
};
}, [isTitleVisible]);
+ useEffect(() => {
+ if (onScrollTitleRef.current)
+ onScrollTitleRef.current.defaultValue = title;
+ }, [title]);
+
const tools = useMemo(
() => [
{
@@ -216,6 +222,7 @@ function Toolbar() {
}}
/>
<AnimatedInput
+ ref={onScrollTitleRef}
variant="clean"
ml={[2, 2, 0]}
initial={{