fix: Sidebar jumps when creating a document from the inline input

This commit is contained in:
Tom Moor committed 2026-11-14 23:09:49 -05:00
1 parent 4a96de653b
commit 81fce61f0c
2 files changed
+8 -2

No files matched your search

@@ -2,6 +2,7 @@ import type { Location, LocationDescriptor } from "history";
import { observer } from "mobx-react";
import { PlusIcon } from "outline-icons";
import * as React from "react";
import { flushSync } from "react-dom";
import { useTranslation } from "react-i18next";
import { mergeRefs } from "react-merge-refs";
import type { match } from "react-router";
@@ -149,7 +150,9 @@ function CollectionRow({
try {
newChildTitleRef.current?.setIsEditing(false);
await onCreateChild(value);
closeAddingNewChild();
// Remove the input in the same paint as the new tree item.
flushSync(closeAddingNewChild);
} catch (_err) {
newChildTitleRef.current?.setIsEditing(true);
}
@@ -2,6 +2,7 @@ import type { Location, LocationDescriptor } from "history";
import { observer } from "mobx-react";
import { PlusIcon } from "outline-icons";
import * as React from "react";
import { flushSync } from "react-dom";
import { useTranslation } from "react-i18next";
import type { match } from "react-router";
import styled from "styled-components";
@@ -194,7 +195,9 @@ function DocumentRow({
try {
newChildTitleRef.current?.setIsEditing(false);
await onCreateChild(value);
closeAddingNewChild();
// Remove the input in the same paint as the new tree item.
flushSync(closeAddingNewChild);
} catch (_err) {
newChildTitleRef.current?.setIsEditing(true);
}