diff --git a/src/Modal/Modal.dropdownExample.js b/src/Modal/Modal.dropdownExample.js new file mode 100644 index 0000000..750ee59 --- /dev/null +++ b/src/Modal/Modal.dropdownExample.js @@ -0,0 +1,65 @@ +import React from 'react'; +import Modal from './Modal'; +import Button from '../Button'; +import Input from '../Form/Input'; +import Dropdown from '../Dropdown'; + +export default class ModalDropdownDemo extends React.Component { + state = { + isModalOpen: false, + }; + + toggle = () => { + this.setState({ isModalOpen: !this.state.isModalOpen }); + }; + + onCancel = () => { + this.toggle(); + + setTimeout(() => { + alert('Oh no! It has been canceled.'); + }, 500); + }; + + render() { + const { body, ...props } = this.props; + + return ( +
+ Open Dropdown}> + + + + Section One + + Open Modal + + + + Footer + + + + + <> + {body} + + + + + + + + + + +
+ ); + } +} diff --git a/src/Modal/Modal.example.js b/src/Modal/Modal.example.js index 2f83311..2d46d14 100644 --- a/src/Modal/Modal.example.js +++ b/src/Modal/Modal.example.js @@ -1,7 +1,7 @@ import React from 'react'; import Modal from './Modal'; import Button from '../Button'; -import Box from '../Box'; +import Input from '../Form/Input'; export default class ModalDemo extends React.Component { state = { @@ -32,11 +32,22 @@ export default class ModalDemo extends React.Component {
- + - {body} + <> + {body} + + - + {bodyTwo} diff --git a/src/Modal/Modal.js b/src/Modal/Modal.js index ade8f15..5a931ce 100644 --- a/src/Modal/Modal.js +++ b/src/Modal/Modal.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { keyframes, css } from 'styled-components'; import * as animations from 'react-animations'; import { Transition } from 'react-transition-group'; +import FocusLock from 'react-focus-lock'; import Portal from '../Portal'; import Flex from '../Flex'; import Box from '../Box'; @@ -105,10 +106,12 @@ function Modal({ children, title, animationDuration, showClose, onClose, open, . {state => ( - - {title && } - {children} - + + + {title && } + {children} + + )} diff --git a/src/Modal/Modal.mdx b/src/Modal/Modal.mdx index 56d3b5a..f7b3bb0 100644 --- a/src/Modal/Modal.mdx +++ b/src/Modal/Modal.mdx @@ -6,6 +6,7 @@ name: Modal import { Playground, PropsTable } from 'docz' import Modal from './Modal' import ModalExample from './Modal.example' +import ModalDropdownExample from './Modal.dropdownexample' # Modal @@ -29,3 +30,11 @@ When modals become too long for the user’s viewport or device, they scroll ind {new Array(50).fill(null).map((_, i) =>

I'm really long annoying content.

)}
} /> + +## Handling Dropdown Triggered Content + +When modals are triggered by dropdowns with returnFocus set to true, modals still receive focus. + + + +