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

Missing export for ModalHeader #6226

Closed
3 tasks done
sdumjahn opened this issue Feb 1, 2022 · 4 comments · Fixed by #6228
Closed
3 tasks done

Missing export for ModalHeader #6226

sdumjahn opened this issue Feb 1, 2022 · 4 comments · Fixed by #6228

Comments

@sdumjahn
Copy link

sdumjahn commented Feb 1, 2022

Prerequisites

Describe the bug

The export of ModalHeader is missing in src/index.tsx.

Expected behavior

The component ModalHeader is exported like the other components from the Modal (e.g. ModalTitle, ModalFooter, ...)

To Reproduce

You get an error when importing the component:

import { Modal, ModalBody, ModalFooter, ModalHeader, ModalTitle } from 'react-bootstrap';

...

Reproducible Example

import React from 'react';
import { Button, Modal, ModalBody, ModalFooter, ModalHeader, ModalTitle } from 'react-bootstrap';

export const TestComponent = () => {
   return (
       <Modal show>
          <ModalHeader closeButton>
             <ModalTitle>Title</ModalTitle>
          </ModalHeader>

          <ModalBody>The Body</ModalBody>

          <ModalFooter className="bg-light">
             <Button variant="outline-link">
                Close
             </Button>
          </ModalFooter>
       </Modal>
   );
};

Screenshots

No response

What operating system(s) are you seeing the problem on?

macOS

What browser(s) are you seeing the problem on?

No response

What version of React-Bootstrap are you using?

2.1.2

What version of Bootstrap are you using?

5.1

Additional context

No response

@sdumjahn sdumjahn added the bug label Feb 1, 2022
@VibhorJaiswal
Copy link
Contributor

VibhorJaiswal commented Feb 1, 2022

It is exported like this in src/Modal.tsx

image

So, according to documentation you can use

<Modal.Header closeButton> <Modal.Title>Modal title</Modal.Title> </Modal.Header>
https://react-bootstrap.github.io/components/modal/

@sdumjahn
Copy link
Author

sdumjahn commented Feb 1, 2022

@VibhorJaiswal: That is technically correct, but:

I need to mock the components from react-bootstrap to be able to use snapshot testing.

e.g.

// src/__mocks__/react-bootstrap.tsx
export const Modal = 'Modal';
export const ModalHeader = 'ModalHeader';
export const ModalTitle = 'ModalTitle';
export const ModalBody = 'ModalBody';
export const ModalFooter = 'ModalFooter';
// src/__tests__/TestComponent.tsx
import React from 'react';
import renderer from 'react-test-renderer';
import { TestComponent } from '../TestComponent';


it('should match snapshot', () => {
   expect(renderer.create(<TestComponent />).toJSON()).toMatchSnapshot();
});

When I use Modal.Header/Modal.Title/..., I am not able to mock them to get them work with snapshot testing.
If there are any other mocking solution to get them work with the namespace using, I am happy to hear them.

And furthermore it is inconsistent when the other components like 'ModalTitle/ModalFooter´/... are exported but ModalHeader not.

@kyletsang
Copy link
Member

We should add this since others are exposed from the index. PRs are welcome

@VibhorJaiswal
Copy link
Contributor

I would like to work on it.

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

Successfully merging a pull request may close this issue.

3 participants