Skip to content

Commit

Permalink
feat: Move modal close before the header for better focus ordering. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenh authored Jun 5, 2024
1 parent 3a8d0c4 commit d15abae
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,17 @@ export function Modal(props: ModalProps) {
{...modalProps}
{...testId}
>
{/* Setup three children (header, content, footer), and flex grow the content. */}
<header css={Css.df.p3.fs0.if(drawHeaderBorder).bb.bcGray200.$}>
<h1 css={Css.fg1.xl2Sb.gray900.$} ref={modalHeaderRef} {...titleProps} {...testId.title} />
{/*
Setup three children (header, content, footer), and flex grow the content.
Use `fdrr` so that the close icon won't sit between "modal header search field"
and the modal body results in the DOM focus order, i.e. in our global search modal.
*/}
<header css={Css.df.fdrr.p3.fs0.if(drawHeaderBorder).bb.bcGray200.$}>
<span css={Css.fs0.pl1.$}>
<IconButton icon="x" onClick={closeModal} {...testId.titleClose} />
</span>
<h1 css={Css.fg1.xl2Sb.gray900.$} ref={modalHeaderRef} {...titleProps} {...testId.title} />
</header>
<main ref={modalBodyRef} css={Css.fg1.oya.if(hasScroll).bb.bcGray200.if(!!forceScrolling).oys.$}>
{/* We'll include content here, but we expect ModalBody and ModalFooter to use their respective portals. */}
Expand Down

0 comments on commit d15abae

Please sign in to comment.