Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 31a8ef0

Browse files
committed
Fix new tab selection when closing one
1 parent b016631 commit 31a8ef0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ui/src/components/DatabaseViewerDialog.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default function DatabaseViewerDialog({
6262
}
6363

6464
const handleCloseTab = (event, tab: string) => {
65-
event.preventDefault();
65+
event.stopPropagation();
6666

6767
const index = tabs.findIndex(t => t.name === tab);
6868

@@ -77,14 +77,13 @@ export default function DatabaseViewerDialog({
7777
return;
7878
}
7979

80-
8180
if (selectedTab === tab) {
82-
let newlySelectedTab = tabs[index + 1].name;
81+
let newlySelectedTabIndex = index + 1;
8382
if (index === tabs.length - 1) {
84-
newlySelectedTab = tabs[index - 1].name;
83+
newlySelectedTabIndex = index - 1;
8584
}
8685

87-
setSelectedTab(newlySelectedTab);
86+
setSelectedTab(tabs[newlySelectedTabIndex].name);
8887
}
8988

9089
setTabs(tabs.filter(t => t.name !== tab));

0 commit comments

Comments
 (0)