diff --git a/src/Explorer/Tabs/Tabs.tsx b/src/Explorer/Tabs/Tabs.tsx index d4588b19e..26b9f1351 100644 --- a/src/Explorer/Tabs/Tabs.tsx +++ b/src/Explorer/Tabs/Tabs.tsx @@ -145,6 +145,8 @@ function TabNav({ tab, active, tabKind }: { tab?: Tab; active: boolean; tabKind? return ko.observable(ReactTabKind[tabKind]); }; + const tabTitle = useObservable(tab?.tabTitle || getReactTabTitle()); + useEffect(() => { if (active && focusTab.current) { focusTab.current.focus(); @@ -156,6 +158,7 @@ function TabNav({ tab, active, tabKind }: { tab?: Tab; active: boolean; tabKind? onMouseLeave={() => setHovering(false)} className={active ? "active tabList" : "tabList"} style={active ? { fontWeight: "bolder" } : {}} + role="presentation" >
@@ -197,10 +200,10 @@ function TabNav({ tab, active, tabKind }: { tab?: Tab; active: boolean; tabKind? /> )} - {useObservable(tab?.tabTitle || getReactTabTitle())} + {tabTitle} - +
@@ -208,22 +211,31 @@ function TabNav({ tab, active, tabKind }: { tab?: Tab; active: boolean; tabKind? ); } +const onKeyPressReactTabClose = (e: KeyboardEvent, tabKind: ReactTabKind): void => { + if (e.key === "Enter" || e.code === "Space") { + useTabs.getState().closeReactTab(tabKind); + e.stopPropagation(); + } +}; + const CloseButton = ({ tab, active, hovering, tabKind, + ariaLabel, }: { tab: Tab; active: boolean; hovering: boolean; tabKind?: ReactTabKind; + ariaLabel: string; }) => ( ) => { event.stopPropagation(); @@ -231,10 +243,10 @@ const CloseButton = ({ // tabKind === ReactTabKind.QueryCopilot && useQueryCopilot.getState().resetQueryCopilotStates(); }} tabIndex={active ? 0 : undefined} - onKeyPress={({ nativeEvent: e }) => tab.onKeyPressClose(undefined, e)} + onKeyPress={({ nativeEvent: e }) => (tab ? tab.onKeyPressClose(undefined, e) : onKeyPressReactTabClose(e, tabKind))} > - Close + Close );