From cb15ef6f2284778a33c28160bcf97f80f14493f8 Mon Sep 17 00:00:00 2001 From: Satyapriya Bai Date: Mon, 13 May 2024 10:51:54 +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 | 7 +++++-- .../Controls/TreeComponent/TreeComponent.tsx | 7 ++++--- .../DeleteCollectionConfirmationPane.tsx | 12 +++++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Explorer/ContextMenuButtonFactory.tsx b/src/Explorer/ContextMenuButtonFactory.tsx index d9f9f3439..5c8649b51 100644 --- a/src/Explorer/ContextMenuButtonFactory.tsx +++ b/src/Explorer/ContextMenuButtonFactory.tsx @@ -132,13 +132,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/TreeComponent.tsx b/src/Explorer/Controls/TreeComponent/TreeComponent.tsx index 4cf601047..9e5fbbaa4 100644 --- a/src/Explorer/Controls/TreeComponent/TreeComponent.tsx +++ b/src/Explorer/Controls/TreeComponent/TreeComponent.tsx @@ -24,7 +24,7 @@ import * as TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcesso export interface TreeNodeMenuItem { label: string; - onClick: () => void; + onClick: (value?: React.RefObject) => void; iconSrc?: string; isDisabled?: boolean; styleClass?: string; @@ -242,8 +242,9 @@ export class TreeNodeComponent extends React.Component +
{ - menuItem.onClick(); + menuItem.onClick(this.contextMenuRef); TelemetryProcessor.trace(Action.ClickResourceTreeNodeContextMenuItem, ActionModifiers.Mark, { label: menuItem.label, }); diff --git a/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx b/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx index 05eff191f..2a8bc49a1 100644 --- a/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx +++ b/src/Explorer/Panes/DeleteCollectionConfirmationPane/DeleteCollectionConfirmationPane.tsx @@ -12,17 +12,19 @@ import { getCollectionName } from "Utils/APITypeUtils"; import * as NotificationConsoleUtils from "Utils/NotificationConsoleUtils"; import { useSidePanel } from "hooks/useSidePanel"; import { useTabs } from "hooks/useTabs"; -import React, { FunctionComponent, useState } from "react"; +import React, { FunctionComponent, useEffect, useState } from "react"; import { useDatabases } from "../../useDatabases"; import { useSelectedNode } from "../../useSelectedNode"; import { RightPaneForm, RightPaneFormProps } from "../RightPaneForm/RightPaneForm"; export interface DeleteCollectionConfirmationPaneProps { refreshDatabases: () => Promise; + lastFocusedElement: React.MutableRefObject; } export const DeleteCollectionConfirmationPane: FunctionComponent = ({ refreshDatabases, + lastFocusedElement, }: DeleteCollectionConfirmationPaneProps) => { const closeSidePanel = useSidePanel((state) => state.closeSidePanel); const [deleteCollectionFeedback, setDeleteCollectionFeedback] = useState(""); @@ -35,6 +37,7 @@ export const DeleteCollectionConfirmationPane: FunctionComponent => { const collection = useSelectedNode.getState().findSelectedCollection(); @@ -111,6 +114,13 @@ export const DeleteCollectionConfirmationPane: FunctionComponent { + return () => { + if (lastItemElement) { + lastItemElement.focus(); + } + }; + }, [lastItemElement]); return (