Skip to content

Commit

Permalink
[WNMGDS-385] - Update dialog to focus on window (#639)
Browse files Browse the repository at this point in the history
* update dialog

* update snapshot

* Add extra div for `dialog-content`

* Update snapshot

Co-authored-by: Bernard <[email protected]>
  • Loading branch information
line47 and bernardwang authored Mar 5, 2020
1 parent 084d80f commit 7170deb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 13 deletions.
9 changes: 7 additions & 2 deletions packages/core/src/components/Dialog/Dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ export const Dialog = function(props) {
return (
<AriaModal
dialogClass={dialogClassNames}
focusDialog
escapeExits={!escapeExitDisabled}
includeDefaultStyles={false}
onExit={onExit}
titleId="dialog-title"
titleId="dialog-title dialog-content"
underlayClass="ds-c-dialog-wrap"
{...modalProps}
>
Expand All @@ -69,7 +70,11 @@ export const Dialog = function(props) {
{closeText}
</Button>
</header>
<main role="main">{children}</main>
<main role="main">
<div id="dialog-content">
{children}
</div>
</main>
{actions && (
<aside className={actionsClassNames} role="complementary">
{actions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Object {
"wrapper": <Displaced
dialogClass="ds-c-dialog ds-base"
escapeExits={true}
focusDialog={true}
includeDefaultStyles={false}
mounted={true}
titleId="dialog-title"
titleId="dialog-title dialog-content"
underlayClass="ds-c-dialog-wrap"
underlayClickExits={false}
>
Expand All @@ -35,7 +36,11 @@ Object {
<main
role="main"
>
Foo
<div
id="dialog-content"
>
Foo
</div>
</main>
</div>
</Displaced>,
Expand All @@ -62,6 +67,7 @@ exports[`Dialog renders react-aria-modal 1`] = `
<Displaced
dialogClass="ds-c-dialog ds-base"
escapeExits={true}
focusDialog={true}
getApplicationNode={
[MockFunction] {
"calls": Array [
Expand All @@ -72,7 +78,7 @@ exports[`Dialog renders react-aria-modal 1`] = `
includeDefaultStyles={false}
mounted={true}
onExit={[MockFunction]}
titleId="dialog-title"
titleId="dialog-title dialog-content"
underlayClass="ds-c-dialog-wrap"
underlayClickExits={false}
>
Expand All @@ -84,10 +90,11 @@ exports[`Dialog renders react-aria-modal 1`] = `
class="ds-c-dialog-wrap"
>
<div
aria-labelledby="dialog-title"
aria-labelledby="dialog-title dialog-content"
class="ds-c-dialog ds-base"
id="react-aria-modal-dialog"
role="dialog"
tabindex="-1"
>
<div
role="document"
Expand All @@ -113,7 +120,11 @@ exports[`Dialog renders react-aria-modal 1`] = `
<main
role="main"
>
Bar
<div
id="dialog-content"
>
Bar
</div>
</main>
</div>
</div>
Expand All @@ -126,6 +137,7 @@ exports[`Dialog renders react-aria-modal 1`] = `
dialogClass="ds-c-dialog ds-base"
dialogId="react-aria-modal-dialog"
escapeExits={true}
focusDialog={true}
focusTrapPaused={false}
getApplicationNode={
[MockFunction] {
Expand All @@ -138,7 +150,7 @@ exports[`Dialog renders react-aria-modal 1`] = `
mounted={true}
onExit={[MockFunction]}
scrollDisabled={true}
titleId="dialog-title"
titleId="dialog-title dialog-content"
underlayClass="ds-c-dialog-wrap"
underlayClickExits={false}
underlayColor="rgba(0,0,0,0.5)"
Expand All @@ -149,7 +161,7 @@ exports[`Dialog renders react-aria-modal 1`] = `
active={true}
focusTrapOptions={
Object {
"initialFocus": undefined,
"initialFocus": "#react-aria-modal-dialog",
}
}
paused={false}
Expand All @@ -161,12 +173,13 @@ exports[`Dialog renders react-aria-modal 1`] = `
style={Object {}}
>
<div
aria-labelledby="dialog-title"
aria-labelledby="dialog-title dialog-content"
className="ds-c-dialog ds-base"
id="react-aria-modal-dialog"
key="b"
role="dialog"
style={Object {}}
tabIndex="-1"
>
<div
role="document"
Expand Down Expand Up @@ -201,7 +214,11 @@ exports[`Dialog renders react-aria-modal 1`] = `
<main
role="main"
>
Bar
<div
id="dialog-content"
>
Bar
</div>
</main>
</div>
</div>
Expand Down Expand Up @@ -229,9 +246,10 @@ Object {
"wrapper": <Displaced
dialogClass="ds-c-dialog ds-base test-dialog ds-c-dialog--full"
escapeExits={true}
focusDialog={true}
includeDefaultStyles={false}
mounted={true}
titleId="dialog-title"
titleId="dialog-title dialog-content"
underlayClass="ds-c-dialog-wrap"
underlayClickExits={false}
>
Expand All @@ -254,7 +272,11 @@ Object {
<main
role="main"
>
Foo
<div
id="dialog-content"
>
Foo
</div>
</main>
<aside
className="ds-c-dialog__actions test-action"
Expand Down

0 comments on commit 7170deb

Please sign in to comment.