Skip to content

Commit

Permalink
fix: modal body className (#15779)
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-chase authored and tw15egan committed Feb 22, 2024
1 parent 957667f commit 7478294
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
10 changes: 10 additions & 0 deletions packages/react/src/components/ComposedModal/ComposedModal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ describe('ComposedModal', () => {
);
});

it('supports a custom class on the modal body', () => {
render(
<ComposedModal>
<ModalBody className="custom-class" data-testid="modal-body" />
</ComposedModal>
);

expect(screen.getByTestId('modal-body')).toHaveClass('custom-class');
});

it('should spread props onto the outermost div', () => {
render(<ComposedModal data-testid="modal" />);

Expand Down
15 changes: 9 additions & 6 deletions packages/react/src/components/ComposedModal/ComposedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ export const ModalBody = React.forwardRef<HTMLDivElement, ModalBodyProps>(
const prefix = usePrefix();
const contentRef = useRef<HTMLDivElement>(null);
const [isScrollable, setIsScrollable] = useState(false);
const contentClass = cx({
[`${prefix}--modal-content`]: true,
[`${prefix}--modal-content--with-form`]: hasForm,
[`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable,
customClassName,
});
const contentClass = cx(
{
[`${prefix}--modal-content`]: true,
[`${prefix}--modal-content--with-form`]: hasForm,
[`${prefix}--modal-scroll-content`]:
hasScrollingContent || isScrollable,
},
customClassName
);

useIsomorphicEffect(() => {
if (contentRef.current) {
Expand Down

0 comments on commit 7478294

Please sign in to comment.