From 62c76cc264241f4ada36b58bf8af6dc5400c18e0 Mon Sep 17 00:00:00 2001 From: SATYA SB <107645008+satya07sb@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:06:35 +0530 Subject: [PATCH] [accessibility-2280341]:[Keyboard Navigation - Azure Cosmos DB - Graph]: Keyboard focus order is not logical after selecting any tab control. (#1854) * [accessibility-2280341]:[Keyboard Navigation - Azure Cosmos DB - Graph]: Keyboard focus order is not logical after selecting any tab control. * updated module structure. --------- Co-authored-by: Satyapriya Bai --- src/Explorer/Controls/Tabs/TabComponent.less | 32 +++------- src/Explorer/Controls/Tabs/TabComponent.tsx | 64 ++++++------------- .../GraphExplorer.test.tsx | 23 ++----- 3 files changed, 38 insertions(+), 81 deletions(-) diff --git a/src/Explorer/Controls/Tabs/TabComponent.less b/src/Explorer/Controls/Tabs/TabComponent.less index 4de5d8974..0d4fd79b2 100644 --- a/src/Explorer/Controls/Tabs/TabComponent.less +++ b/src/Explorer/Controls/Tabs/TabComponent.less @@ -1,28 +1,16 @@ @import "../../../../less/Common/Constants"; .tabComponentContainer { - height: 100%; - .flex-display(); - .flex-direction(); + height: 100%; + .flex-display(); + .flex-direction(); - .tabSwitch { - margin-left: @LargeSpace; - margin-bottom: 20px; + .tabSwitch { + margin-left: @LargeSpace; + margin-bottom: 20px; - .tab { - margin-right: @MediumSpace; - } - - .toggleSwitch { - .toggleSwitch(); - } - - .selectedToggle { - .selectedToggle(); - } - - .unselectedToggle { - .unselectedToggle(); - } - } + .tab { + margin-right: @MediumSpace; + } + } } diff --git a/src/Explorer/Controls/Tabs/TabComponent.tsx b/src/Explorer/Controls/Tabs/TabComponent.tsx index 9cfcf8ae5..d414bcefb 100644 --- a/src/Explorer/Controls/Tabs/TabComponent.tsx +++ b/src/Explorer/Controls/Tabs/TabComponent.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import { AccessibleElement } from "../../Controls/AccessibleElement/AccessibleElement"; +import { Pivot, PivotItem } from "@fluentui/react"; import "./TabComponent.less"; export interface TabContent { @@ -35,58 +35,36 @@ export class TabComponent extends React.Component { } private setActiveTab(index: number): void { - this.setState({ activeTabIndex: index }); this.props.onTabIndexChange(index); } - private renderTabTitles(): JSX.Element[] { - return this.props.tabs.map((tab: Tab, index: number) => { - if (!tab.isVisible()) { - return ; - } - - let className = "toggleSwitch"; - let ariaselected; - if (index === this.props.currentTabIndex) { - className += " selectedToggle"; - ariaselected = true; - } else { - className += " unselectedToggle"; - ariaselected = false; - } - - return ( -
- this.setActiveTab(index)} - aria-label={`Select tab: ${tab.title}`} - aria-selected={ariaselected} - > - {tab.title} - -
- ); - }); - } - public render(): JSX.Element { - const currentTabContent = this.props.tabs[this.props.currentTabIndex].content; + const { tabs, currentTabIndex, hideHeader } = this.props; + const currentTabContent = tabs[currentTabIndex].content; let className = "tabComponentContent"; if (currentTabContent.className) { className += ` ${currentTabContent.className}`; } - return (
- {!this.props.hideHeader && ( -
- {this.renderTabTitles()} -
- )} -
{currentTabContent.render()}
+
+ {!hideHeader && ( + this.setActiveTab(parseInt(item?.props.itemKey || ""))} + > + {tabs.map((tab: Tab, index: number) => { + if (!tab.isVisible()) { + return null; // Skip rendering invisible tabs + } + return ; + })} + + )} +
+
{tabs[currentTabIndex].content.render()}
); } diff --git a/src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.test.tsx b/src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.test.tsx index eacba9648..e408adac7 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.test.tsx +++ b/src/Explorer/Graph/GraphExplorerComponent/GraphExplorer.test.tsx @@ -632,24 +632,15 @@ describe("GraphExplorer", () => { it("should display RU consumption", () => { // Find link for query stats - const links = wrapper.find(".toggleSwitch"); + const queryStatsTab = wrapper.find(`button[name="${GraphExplorer.QUERY_STATS_BUTTON_LABEL}"]`); + queryStatsTab.simulate("click"); + const values = wrapper.find(".queryMetricsSummary td"); let isRUDisplayed = false; - for (let i = 0; i < links.length; i++) { - const link = links.at(i); - if (link.text() === GraphExplorer.QUERY_STATS_BUTTON_LABEL) { - link.simulate("click"); - - const values = wrapper.find(".queryMetricsSummary td"); - for (let j = 0; j < values.length; j++) { - if (Number(values.at(j).text()) === gVRU) { - isRUDisplayed = true; - break; - } - } - break; + values.forEach((value) => { + if (Number(value.text()) === gVRU) { + isRUDisplayed = true; } - } - + }); expect(isRUDisplayed).toBe(true); }); });