Skip to content

Commit 17b51e9

Browse files
committed
address PR feedback on tables tab sync
1 parent 1d07c46 commit 17b51e9

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

ui/src/routes/tables.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ function Tables() {
4747
</Card>
4848
);
4949

50-
const requestedTableMissing =
51-
!!table && !data.tables.some(({ name }) => name === table);
50+
const requestedTableIndex = table
51+
? data.tables.findIndex(({ name }) => name === table)
52+
: -1;
5253

53-
const tab = (() => {
54-
if (!table) return "0";
55-
const index = data.tables.findIndex(({ name }) => name === table);
56-
return (index >= 0 ? index : 0).toString();
57-
})();
54+
const requestedTableMissing = !!table && requestedTableIndex < 0;
55+
const tab = String(Math.max(requestedTableIndex, 0));
5856

5957
return (
6058
<>
@@ -70,7 +68,7 @@ function Tables() {
7068
</Card>
7169
)}
7270

73-
<Tabs defaultValue={tab}>
71+
<Tabs key={tab} defaultValue={tab}>
7472
<TabsList>
7573
{data.tables.map((n, i) => (
7674
<TabsTrigger key={i} value={i.toString()}>

0 commit comments

Comments
 (0)