diff --git a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx index 14645d878..f2bcdb23b 100644 --- a/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx +++ b/src/Explorer/Tabs/DocumentsTabV2/DocumentsTabV2.tsx @@ -187,7 +187,7 @@ export class DocumentsTabV2 extends TabsBase { partitionKey: this.partitionKey, documentIds: ko.observableArray([]), tabKind: ViewModels.CollectionTabKind.Documents, - title: "Items", + title: this.tabTitle(), collection: this.collection, node: this.collection, tabPath: `${this.collection.databaseId}>${this.collection.id()}>Documents`, diff --git a/src/Explorer/Tabs/Tabs.tsx b/src/Explorer/Tabs/Tabs.tsx index 186a5b5bd..aae8a6fb0 100644 --- a/src/Explorer/Tabs/Tabs.tsx +++ b/src/Explorer/Tabs/Tabs.tsx @@ -87,95 +87,93 @@ function TabNav({ tab, active, tabKind }: { tab?: Tab; active: boolean; tabKind? focusTab.current.focus(); } }, [active]); + const liElement = ( +
  • setHovering(true)} + onMouseLeave={() => setHovering(false)} + className={active ? "active tabList" : "tabList"} + style={active ? { fontWeight: "bolder" } : {}} + role="presentation" + > + +
    + + { + if (tab) { + tab.onTabClick(); + } else if (tabKind !== undefined) { + useTabs.getState().activateReactTab(tabKind); + } + }} + onKeyPress={({ nativeEvent: e }) => { + if (tab) { + tab.onKeyPressActivate(undefined, e); + } else if (tabKind !== undefined) { + onKeyPressReactTab(e, tabKind); + } + }} + aria-selected={active} + aria-expanded={active} + aria-controls={tabId} + tabIndex={0} + role="tab" + ref={focusTab} + > + + {useObservable(tab?.isExecutionError || ko.observable(false)) && ( + + )} + {useObservable(tab?.isExecutionWarning || ko.observable(false)) && ( + + )} + {isTabExecuting(tab, tabKind) && ( + + )} + {isQueryErrorThrown(tab, tabKind) && ( + + Error + + )} + + {tabTitle} + + + + + +
    +
    +
  • + ); + + if (!tab?.canDuplicate()) { + return liElement; + } + return ( - -
  • setHovering(true)} - onMouseLeave={() => setHovering(false)} - className={active ? "active tabList" : "tabList"} - style={active ? { fontWeight: "bolder" } : {}} - role="presentation" - > - -
    - - { - if (tab) { - tab.onTabClick(); - } else if (tabKind !== undefined) { - useTabs.getState().activateReactTab(tabKind); - } - }} - onKeyPress={({ nativeEvent: e }) => { - if (tab) { - tab.onKeyPressActivate(undefined, e); - } else if (tabKind !== undefined) { - onKeyPressReactTab(e, tabKind); - } - }} - aria-selected={active} - aria-expanded={active} - aria-controls={tabId} - tabIndex={0} - role="tab" - ref={focusTab} - > - - {useObservable(tab?.isExecutionError || ko.observable(false)) && ( - - )} - {useObservable(tab?.isExecutionWarning || ko.observable(false)) && ( - - )} - {isTabExecuting(tab, tabKind) && ( - - )} - {isQueryErrorThrown(tab, tabKind) && ( - - Error - - )} - - {tabTitle} - - - - - -
    -
    -
  • -
    + {liElement} - {tab?.canDuplicate() && ( - tab.duplicateTab()}>{t(Keys.tabs.tabMenu.duplicateTab)} - )} - { - tab ? tab.onCloseTabButtonClick() : useTabs.getState().closeReactTab(tabKind); - }} - > - {t(Keys.tabs.tabMenu.closeTab)} - + tab.duplicateTab()}>{t(Keys.tabs.tabMenu.duplicateTab)} + tab.onCloseTabButtonClick()}>{t(Keys.tabs.tabMenu.closeTab)}
    diff --git a/test/sql/duplicateTab.spec.ts b/test/sql/duplicateTab.spec.ts index eeaf40e32..e91322e0f 100644 --- a/test/sql/duplicateTab.spec.ts +++ b/test/sql/duplicateTab.spec.ts @@ -77,15 +77,13 @@ test("Duplicate Query tab preserves query text in new tab", async () => { expect(editorText).toContain("duplicate-query-test"); }); -test("Duplicate tab menu item is not shown for the Home tab", async () => { - // The Home tab (ReactTabKind) is never duplicable +test("Right-click context menu does not appear for the Home tab", async () => { + // The Home tab (ReactTabKind) is never duplicable — no context menu should appear await explorer.tabNavHeader("Home").click({ button: "right" }); - // "Close tab" should always appear - await expect(explorer.tabContextMenuItem("Close tab")).toBeVisible(); - - // "Duplicate tab" must NOT appear + // Neither menu item should be visible await expect(explorer.tabContextMenuItem("Duplicate tab")).not.toBeVisible(); + await expect(explorer.tabContextMenuItem("Close tab")).not.toBeVisible(); }); test("Close tab from right-click menu closes the tab", async () => {