From 81a4c8039b7e42d974d5e96ab5bb0fb9098866fa Mon Sep 17 00:00:00 2001 From: Satyapriya Bai Date: Wed, 19 Jun 2024 15:12:44 +0530 Subject: [PATCH] [accessibility-2262594]:[Keyboard Navigation - Azure Cosmos DB - Data Explorer]: Keyboard focus is not retaining back to 'more' button after closing 'Delete container' dialog. --- src/Explorer/ContextMenuButtonFactory.tsx | 14 ++++++++++---- .../Controls/TreeComponent/TreeNodeComponent.tsx | 8 +++++--- .../__snapshots__/TreeNodeComponent.test.tsx.snap | 8 ++++---- .../DeleteCollectionConfirmationPane.tsx | 14 ++++++++++++-- .../Panes/DeleteDatabaseConfirmationPanel.tsx | 13 +++++++++++-- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/Explorer/ContextMenuButtonFactory.tsx b/src/Explorer/ContextMenuButtonFactory.tsx index 90c78e365..d4186ba27 100644 --- a/src/Explorer/ContextMenuButtonFactory.tsx +++ b/src/Explorer/ContextMenuButtonFactory.tsx @@ -52,12 +52,15 @@ export const createDatabaseContextMenu = (container: Explorer, databaseId: strin if (userContext.apiType !== "Tables" || userContext.features.enableSDKoperations) { items.push({ iconSrc: DeleteDatabaseIcon, - onClick: () => + onClick: (lastFocusedElement?: React.RefObject) => useSidePanel .getState() .openSidePanel( "Delete " + getDatabaseName(), - container.refreshAllDatabases()} />, + container.refreshAllDatabases()} + />, ), label: `Delete ${getDatabaseName()}`, styleClass: "deleteDatabaseMenuItem", @@ -132,13 +135,16 @@ export const createCollectionContextMenuButton = ( if (configContext.platform !== Platform.Fabric) { items.push({ iconSrc: DeleteCollectionIcon, - onClick: () => { + onClick: (lastFocusedElement?: React.RefObject) => { useSelectedNode.getState().setSelectedNode(selectedCollection); useSidePanel .getState() .openSidePanel( "Delete " + getCollectionName(), - container.refreshAllDatabases()} />, + container.refreshAllDatabases()} + />, ); }, label: `Delete ${getCollectionName()}`, diff --git a/src/Explorer/Controls/TreeComponent/TreeNodeComponent.tsx b/src/Explorer/Controls/TreeComponent/TreeNodeComponent.tsx index 9ec2c904a..352b732b8 100644 --- a/src/Explorer/Controls/TreeComponent/TreeNodeComponent.tsx +++ b/src/Explorer/Controls/TreeComponent/TreeNodeComponent.tsx @@ -21,7 +21,7 @@ import { useCallback } from "react"; export interface TreeNodeMenuItem { label: string; - onClick: () => void; + onClick: (value?: React.RefObject) => void; iconSrc?: string; isDisabled?: boolean; styleClass?: string; @@ -73,6 +73,7 @@ export const TreeNodeComponent: React.FC = ({ treeNodeId, }: TreeNodeComponentProps): JSX.Element => { const [isLoading, setIsLoading] = React.useState(false); + const contextMenuRef = React.useRef(null); const getSortedChildren = (treeNode: TreeNode): TreeNode[] => { if (!treeNode || !treeNode.children) { @@ -139,7 +140,7 @@ export const TreeNodeComponent: React.FC = ({ data-test={`TreeNode/ContextMenuItem:${menuItem.label}`} disabled={menuItem.isDisabled} key={menuItem.label} - onClick={menuItem.onClick} + onClick={() => menuItem.onClick(contextMenuRef)} > {menuItem.label} @@ -158,11 +159,12 @@ export const TreeNodeComponent: React.FC = ({ actions={ contextMenuItems.length > 0 && ( - +