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

Padding issue when closing a modal and opening another at the same time #2781

Open
robertwramos opened this issue Nov 15, 2023 · 0 comments · May be fixed by #2782
Open

Padding issue when closing a modal and opening another at the same time #2781

robertwramos opened this issue Nov 15, 2023 · 0 comments · May be fixed by #2782

Comments

@robertwramos
Copy link

Issue description

  • components: Modal
  • reactstrap version master
  • import method umd/csj/es
  • react version 17.0.2
  • bootstrap version 5.3.1

What is happening?

When one modal is closed and another is immediately opened the right padding that is added for the scrollbar width is added to the body when the second modal is closed.

What should be happening?

The original right padding value for the body should be applied when the second modal is closed.

Steps to reproduce issue

  1. Create two modals, 'a' and 'b'.
  2. Set modal 'a' isOpen to true and modal 'b' isOpen to false.
  3. Set modal 'a' isOpen to false and modal 'b' isOpen to true.
  4. Set modal 'b' isOpen to 'false'.

Code

import React, { useState } from "react";
import "bootstrap/dist/css/bootstrap.min.css";
import { Button, Container, Modal } from "reactstrap";

function App() {
  const [firstModalOpen, setFirstModalOpen] = useState(false);
  const [secondModalOpen, setSecondModalOpen] = useState(false);

  return (
    <div className="overflow-scroll bg-primary vh-100">
      <div className="h-100">
        <Button onClick={() => setFirstModalOpen(true)}>Open</Button>
        <Modal isOpen={firstModalOpen}>
          <Button
            onClick={() => {
              setFirstModalOpen(false);
              setSecondModalOpen(true);
            }}
          >
            open second modal
          </Button>
        </Modal>
        <Modal isOpen={secondModalOpen}>
          <Button onClick={() => setSecondModalOpen(false)}>Close</Button>
        </Modal>
      </div>
      <div>overflow content</div>
    </div>
  );
}

export default App;

https://codesandbox.io/s/reactstrap-modal-padding-bug-flrzt5?file=/src/App.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant