mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Modal: Fix restore focus behavior (#43749)
* Modal: Fix restore focus behavior * Use OverlayContainer Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
parent
8717bc7ef4
commit
e7f1e11229
@ -1,5 +1,4 @@
|
||||
import React, { PropsWithChildren, useCallback, useEffect } from 'react';
|
||||
import { Portal } from '../Portal/Portal';
|
||||
import { cx } from '@emotion/css';
|
||||
import { useTheme2 } from '../../themes';
|
||||
import { IconName } from '../../types';
|
||||
@ -8,6 +7,7 @@ import { ModalHeader } from './ModalHeader';
|
||||
import { IconButton } from '../IconButton/IconButton';
|
||||
import { HorizontalGroup } from '../Layout/Layout';
|
||||
import { FocusScope } from '@react-aria/focus';
|
||||
import { OverlayContainer } from '@react-aria/overlays';
|
||||
|
||||
export interface Props {
|
||||
/** @deprecated no longer used */
|
||||
@ -71,7 +71,7 @@ export function Modal(props: PropsWithChildren<Props>) {
|
||||
const headerClass = cx(styles.modalHeader, typeof title !== 'string' && styles.modalHeaderWithTabs);
|
||||
|
||||
return (
|
||||
<Portal>
|
||||
<OverlayContainer>
|
||||
<div
|
||||
className={styles.modalBackdrop}
|
||||
onClick={onClickBackdrop || (closeOnBackdropClick ? onDismiss : undefined)}
|
||||
@ -88,7 +88,7 @@ export function Modal(props: PropsWithChildren<Props>) {
|
||||
<div className={cx(styles.modalContent, contentClassName)}>{children}</div>
|
||||
</div>
|
||||
</FocusScope>
|
||||
</Portal>
|
||||
</OverlayContainer>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ export const getModalStyles = stylesFactory((theme: GrafanaTheme2) => {
|
||||
`,
|
||||
modalBackdrop: css`
|
||||
position: fixed;
|
||||
z-index: ${theme.zIndex.modalBackdrop};
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
|
Loading…
Reference in New Issue
Block a user