From 8dc3aa557cefdafe33ce42cf0f25bfc029d12188 Mon Sep 17 00:00:00 2001 From: Aller05 <421361608@qq.com> Date: Thu, 18 Apr 2024 05:25:04 +0000 Subject: [PATCH] feat: multi tab scrolling optimization --- ui/src/components/EditFlowName.tsx | 1 + ui/src/topbar/multipleTabs/index.tsx | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/src/components/EditFlowName.tsx b/ui/src/components/EditFlowName.tsx index 5476388..c5b1cb1 100644 --- a/ui/src/components/EditFlowName.tsx +++ b/ui/src/components/EditFlowName.tsx @@ -80,6 +80,7 @@ export default function EditFlowName({ displayName, isActive }: Props) { whiteSpace="nowrap" overflow="hidden" textOverflow="ellipsis" + userSelect="none" > {displayName} diff --git a/ui/src/topbar/multipleTabs/index.tsx b/ui/src/topbar/multipleTabs/index.tsx index a92d0a6..74c1bb6 100644 --- a/ui/src/topbar/multipleTabs/index.tsx +++ b/ui/src/topbar/multipleTabs/index.tsx @@ -89,11 +89,14 @@ export default function MultipleTabs() { }); setIsDirty(detail.activeTab.isDirty); curVersion && setCurVersion(null); - document - .getElementById( - `workspace-multiple-tabs-item-${detail.activeTab.id}`, - ) - ?.scrollIntoView({ behavior: "smooth" }); + // Avoid scrolling when the corresponding element has not yet been rendered. + setTimeout(() => { + document + .getElementById( + `workspace-multiple-tabs-item-${detail.activeTab.id}`, + ) + ?.scrollIntoView({ behavior: "smooth" }); + }, 0); break; } };