mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Dialog box of azure synapse closes on pressing escape button (#1543)
This commit is contained in:
parent
d15feb3478
commit
a3bd126a21
@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
ChoiceGroup,
|
ChoiceGroup,
|
||||||
DefaultButton,
|
DefaultButton,
|
||||||
Dialog as FluentDialog,
|
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogType,
|
DialogType,
|
||||||
|
Dialog as FluentDialog,
|
||||||
FontIcon,
|
FontIcon,
|
||||||
IButtonProps,
|
IButtonProps,
|
||||||
IChoiceGroupProps,
|
IChoiceGroupProps,
|
||||||
@ -15,7 +15,7 @@ import {
|
|||||||
ProgressIndicator,
|
ProgressIndicator,
|
||||||
TextField,
|
TextField,
|
||||||
} from "@fluentui/react";
|
} from "@fluentui/react";
|
||||||
import React, { FC } from "react";
|
import React, { FC, useEffect } from "react";
|
||||||
import create, { UseStore } from "zustand";
|
import create, { UseStore } from "zustand";
|
||||||
|
|
||||||
export interface DialogState {
|
export interface DialogState {
|
||||||
@ -157,6 +157,20 @@ export const Dialog: FC = () => {
|
|||||||
contentHtml,
|
contentHtml,
|
||||||
} = props || {};
|
} = props || {};
|
||||||
|
|
||||||
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
useDialog.getState().closeDialog();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (visible) {
|
||||||
|
document.addEventListener("keydown", handleKeyDown);
|
||||||
|
} else {
|
||||||
|
document.removeEventListener("keydown", handleKeyDown);
|
||||||
|
}
|
||||||
|
}, [visible]);
|
||||||
|
|
||||||
const dialogProps: IDialogProps = {
|
const dialogProps: IDialogProps = {
|
||||||
hidden: !visible,
|
hidden: !visible,
|
||||||
dialogContentProps: {
|
dialogContentProps: {
|
||||||
|
Loading…
Reference in New Issue
Block a user