Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Modal): directly show backdrop if no animation (fix: #4190) #4192

Merged
merged 4 commits into from Aug 6, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Modal.js
Expand Up @@ -273,12 +273,16 @@ class Modal extends React.Component {
}

renderBackdrop = props => {
const { bsPrefix, backdropClassName } = this.props;
const { bsPrefix, backdropClassName, animation } = this.props;

return (
<div
{...props}
className={classNames(`${bsPrefix}-backdrop`, backdropClassName)}
className={classNames(
`${bsPrefix}-backdrop`,
backdropClassName,
!animation && 'show',
)}
/>
);
};
Expand Down
31 changes: 31 additions & 0 deletions www/src/examples/Modal/WithoutAnimation.js
@@ -0,0 +1,31 @@
function Example() {
const [show, setShow] = useState(false);

const handleClose = () => setShow(false);
const handleShow = () => setShow(true);

return (
<>
<Button variant="primary" onClick={handleShow}>
Launch demo modal
</Button>

<Modal show={show} onHide={handleClose} animation={false}>
<Modal.Header closeButton>
<Modal.Title>Modal heading</Modal.Title>
</Modal.Header>
<Modal.Body>Woohoo, you're reading this text in a modal!</Modal.Body>
<Modal.Footer>
<Button variant="secondary" onClick={handleClose}>
Close
</Button>
<Button variant="primary" onClick={handleClose}>
Save Changes
</Button>
</Modal.Footer>
</Modal>
</>
);
}

render(<Example />);
9 changes: 9 additions & 0 deletions www/src/pages/components/modal.js
Expand Up @@ -11,6 +11,7 @@ import ModalBasic from '../../examples/Modal/Basic';
import ModalDefaultSizing from '../../examples/Modal/DefaultSizing';
import ModalCustomSizing from '../../examples/Modal/CustomSizing';
import ModalVerticallyCentered from '../../examples/Modal/VerticallyCentered';
import ModalWithoutAnimation from '../../examples/Modal/WithoutAnimation';
import ModalGrid from '../../examples/Modal/Grid';
import withLayout from '../../withLayout';

Expand Down Expand Up @@ -85,6 +86,14 @@ export default withLayout(function ModalSection({ data }) {
content.
</p>
<ReactPlayground codeText={ModalBasic} />
<LinkedHeading h="3" id="modals-live">
Without Animation
</LinkedHeading>
<p>
A Modal can also be without an animation. For that set the "animation"
prop to <code>false</code>.
</p>
<ReactPlayground codeText={ModalWithoutAnimation} />
<div className="bs-callout bs-callout-info">
<div className="h4">Additional Import Options</div>
<p>
Expand Down