Skip to content

Commit 066cbfe

Browse files
committed
fix(chat): preserve synchronous caret updates and popup width
1 parent a522bdf commit 066cbfe

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎apps/web/src/components/BranchToolbarBranchSelector.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,10 @@ export function BranchToolbarBranchSelector({
716716
: {}),
717717
align: "start",
718718
side: displayMode === "panel" ? "right" : "top",
719-
className: cn("flex flex-col", displayMode === "panel" ? "w-(--anchor-width)" : "w-90"),
719+
className: cn(
720+
"flex flex-col",
721+
displayMode === "panel" ? "w-(--anchor-width)" : "min-w-0 w-90",
722+
),
720723
...(displayMode === "toolbar" ? composerFloatingLayerProps : {}),
721724
}}
722725
>

‎apps/web/src/components/ComposerPromptEditorTiptap.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ function ComposerPromptEditorTiptapInner(
15161516
if (!editor) return;
15171517
// Tiptap mounts React node views with flushSync; leave React's commit before updating them.
15181518
let active = true;
1519-
queueMicrotask(() => {
1519+
const applyControlledUpdate = () => {
15201520
if (!active || editor.isDestroyed) return;
15211521
const initialSelection = !hasAppliedControlledSelectionRef.current;
15221522
hasAppliedControlledSelectionRef.current = true;
@@ -1586,7 +1586,10 @@ function ComposerPromptEditorTiptapInner(
15861586
queueMicrotask(() => {
15871587
isApplyingControlledUpdateRef.current = false;
15881588
});
1589-
});
1589+
};
1590+
// Cursor-only updates must precede focus restoration on a rich/plain remount.
1591+
if (snapshotRef.current.value === value) applyControlledUpdate();
1592+
else queueMicrotask(applyControlledUpdate);
15901593
return () => {
15911594
active = false;
15921595
};

0 commit comments

Comments
 (0)