question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to open Drawer inside Modal, div or any container not just htmlBody

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

Opens Drawer where ever developers want, not just html 's body

What does the proposed API look like?

import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { Drawer, Button, Modal, Form } from "antd";

class App extends React.Component {
  state = {
    visibleDrawer: false,
    visibleModal: false
  };

  showDrawer = () => {
    this.setState({
      visibleDrawer: true
    });
  };

  onClose = () => {
    this.setState({
      visibleDrawer: false
    });
  };

  showModal = () => {
    this.setState({
      visibleModal: true
    });
  };

  handleOk = e => {
    console.log(e);
    this.setState({
      visibleModal: false
    });
  };

  handleCancel = e => {
    console.log(e);
    this.setState({
      visibleModal: false
    });
  };

  render() {
    return (
      <div>
        <Button type="primary" onClick={this.showModal}>
          Open Modal
        </Button>
        <Modal
          title="Basic Modal"
          visible={this.state.visibleModal}
          onOk={this.handleOk}
          onCancel={this.handleCancel}
        >
          <Button type="primary" onClick={this.showDrawer}>
            Open Drawer
          </Button>
          <Form>
            <Form.Item>
              <Drawer
                title="Basic Drawer"
                placement="right"
                closable={this.state.visibleDrawer}
                onClose={this.onClose}
                visible={this.state.visibleDrawer}
              >
                <p>Some contents...</p>
                <p>Some contents...</p>
                <p>Some contents...</p>
              </Drawer>
            </Form.Item>
          </Form>
        </Modal>
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById("container"));

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
ccaseirocommented, Apr 8, 2019

Hi, you need to use both getContainer and also style the Drawer with relative postion. I’m using React Hooks to get myRef in the example below:

      <div ref={myElem} />
      <Drawer
        visible={showDrawer}
        placement="top"
        onClose={toggleDrawer}
        getContainer={() => myElem.current}
        style={{ position: "relative", zIndex: 90 }}
      >
        <div>test</div>
      </Drawer>
3reactions
jljsj33commented, Aug 22, 2018
<div id="drawer-container" >
  <Drawer getContainer={false}/>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ability to open Drawer inside Modal, div or any ... - Issuehunt
Ability to open Drawer inside Modal, div or any container not just htmlBody #11671. I have searched the issues of this repository and...
Read more >
Implementing a Modal inside a Drawer in Material UI
I'm using Material UI and im trying to make a Modal pop up from a Responsive Drawer component. The problem is that when...
Read more >
Portals - React
Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component. ReactDOM.createPortal(child, ......
Read more >
CSS Modal Examples That You Can Download and Edit
In this example, programmer Homer Gaines shows how to open a modal window with the CSS :target selector. Again, it does not use...
Read more >
Hennepin County pattern and component library
It contains design elements for county websites and applications. The guide will help developers meet the county's standards and ensure Section 508 compliance....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found