Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "bugfix: enables Escape to dismiss alert Dialog",
"packageName": "@fluentui/react-dialog",
"email": "bernardo.sunderhus@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ describe('Dialog', () => {
});
});
describe('modalType = alert', () => {
it('should not close with escape keydown', () => {
it('should close with escape keydown', () => {
mount(
<Dialog modalType="alert">
<DialogTrigger disableButtonEnhancement>
Expand Down Expand Up @@ -512,7 +512,7 @@ describe('Dialog', () => {
);
cy.get(dialogTriggerOpenSelector).realClick();
cy.focused().realType('{esc}');
cy.get(dialogSurfaceSelector).should('exist');
cy.get(dialogSurfaceSelector).should('not.exist');
});
it('should lock body scroll when dialog open', () => {
mount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@fluentui/react-utilities';
import type { DialogSurfaceElement, DialogSurfaceProps, DialogSurfaceState } from './DialogSurface.types';
import { useDialogContext_unstable } from '../../contexts';
import { isEscapeKeyDismiss } from '../../utils';
import { Escape } from '@fluentui/keyboard-keys';

/**
* Create the state required to render DialogSurface.
Expand Down Expand Up @@ -47,7 +47,7 @@ export const useDialogSurface_unstable = (
const handleKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLDivElement>) => {
props.onKeyDown?.(event);

if (isEscapeKeyDismiss(event, modalType)) {
if (event.key === Escape && !event.isDefaultPrevented()) {
requestOpenChange({
event,
open: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { useDialogTrigger_unstable } from './useDialogTrigger.styles';
import { useDialogTrigger_unstable } from './useDialogTrigger';
import { renderDialogTrigger_unstable } from './renderDialogTrigger';
import type { DialogTriggerProps } from './DialogTrigger.types';
import type { FluentTriggerComponent } from '@fluentui/react-utilities';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './DialogTrigger';
export * from './DialogTrigger.types';
export * from './renderDialogTrigger';
export * from './useDialogTrigger.styles';
export * from './useDialogTrigger';
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './isEscapeKeyDown';
export * from './useDisableBodyScroll';
export * from './useFocusFirstElement';

This file was deleted.