[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 <v-satybai@microsoft.com>
This commit is contained in:
parent
99d95a4cec
commit
62c76cc264
|
@ -12,17 +12,5 @@
|
||||||
.tab {
|
.tab {
|
||||||
margin-right: @MediumSpace;
|
margin-right: @MediumSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toggleSwitch {
|
|
||||||
.toggleSwitch();
|
|
||||||
}
|
|
||||||
|
|
||||||
.selectedToggle {
|
|
||||||
.selectedToggle();
|
|
||||||
}
|
|
||||||
|
|
||||||
.unselectedToggle {
|
|
||||||
.unselectedToggle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { AccessibleElement } from "../../Controls/AccessibleElement/AccessibleElement";
|
import { Pivot, PivotItem } from "@fluentui/react";
|
||||||
import "./TabComponent.less";
|
import "./TabComponent.less";
|
||||||
|
|
||||||
export interface TabContent {
|
export interface TabContent {
|
||||||
|
@ -35,58 +35,36 @@ export class TabComponent extends React.Component<TabComponentProps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private setActiveTab(index: number): void {
|
private setActiveTab(index: number): void {
|
||||||
this.setState({ activeTabIndex: index });
|
|
||||||
this.props.onTabIndexChange(index);
|
this.props.onTabIndexChange(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderTabTitles(): JSX.Element[] {
|
|
||||||
return this.props.tabs.map((tab: Tab, index: number) => {
|
|
||||||
if (!tab.isVisible()) {
|
|
||||||
return <React.Fragment key={index} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
let className = "toggleSwitch";
|
|
||||||
let ariaselected;
|
|
||||||
if (index === this.props.currentTabIndex) {
|
|
||||||
className += " selectedToggle";
|
|
||||||
ariaselected = true;
|
|
||||||
} else {
|
|
||||||
className += " unselectedToggle";
|
|
||||||
ariaselected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="tab" key={index}>
|
|
||||||
<AccessibleElement
|
|
||||||
as="span"
|
|
||||||
className={className}
|
|
||||||
role="tab"
|
|
||||||
onActivated={() => this.setActiveTab(index)}
|
|
||||||
aria-label={`Select tab: ${tab.title}`}
|
|
||||||
aria-selected={ariaselected}
|
|
||||||
>
|
|
||||||
{tab.title}
|
|
||||||
</AccessibleElement>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public render(): JSX.Element {
|
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";
|
let className = "tabComponentContent";
|
||||||
if (currentTabContent.className) {
|
if (currentTabContent.className) {
|
||||||
className += ` ${currentTabContent.className}`;
|
className += ` ${currentTabContent.className}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="tabComponentContainer">
|
<div className="tabComponentContainer">
|
||||||
{!this.props.hideHeader && (
|
<div className="tabs tabSwitch">
|
||||||
<div className="tabs tabSwitch" role="tablist">
|
{!hideHeader && (
|
||||||
{this.renderTabTitles()}
|
<Pivot
|
||||||
</div>
|
aria-label="Tab navigation"
|
||||||
|
selectedKey={currentTabIndex.toString()}
|
||||||
|
linkSize="normal"
|
||||||
|
onLinkClick={(item) => this.setActiveTab(parseInt(item?.props.itemKey || ""))}
|
||||||
|
>
|
||||||
|
{tabs.map((tab: Tab, index: number) => {
|
||||||
|
if (!tab.isVisible()) {
|
||||||
|
return null; // Skip rendering invisible tabs
|
||||||
|
}
|
||||||
|
return <PivotItem key={index} headerText={tab.title} itemKey={index.toString()} />;
|
||||||
|
})}
|
||||||
|
</Pivot>
|
||||||
)}
|
)}
|
||||||
<div className={className}>{currentTabContent.render()}</div>
|
</div>
|
||||||
|
<div className={className}>{tabs[currentTabIndex].content.render()}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,24 +632,15 @@ describe("GraphExplorer", () => {
|
||||||
|
|
||||||
it("should display RU consumption", () => {
|
it("should display RU consumption", () => {
|
||||||
// Find link for query stats
|
// Find link for query stats
|
||||||
const links = wrapper.find(".toggleSwitch");
|
const queryStatsTab = wrapper.find(`button[name="${GraphExplorer.QUERY_STATS_BUTTON_LABEL}"]`);
|
||||||
let isRUDisplayed = false;
|
queryStatsTab.simulate("click");
|
||||||
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");
|
const values = wrapper.find(".queryMetricsSummary td");
|
||||||
for (let j = 0; j < values.length; j++) {
|
let isRUDisplayed = false;
|
||||||
if (Number(values.at(j).text()) === gVRU) {
|
values.forEach((value) => {
|
||||||
|
if (Number(value.text()) === gVRU) {
|
||||||
isRUDisplayed = true;
|
isRUDisplayed = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(isRUDisplayed).toBe(true);
|
expect(isRUDisplayed).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue