Skip to content

Commit b598a40

Browse files
TheSharpieOneeddywashere
authored andcommitted
fix(Modal): add back attribute passthrough (#444)
fixes #443
1 parent 9e4d381 commit b598a40

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/Modal.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
conditionallyUpdateScrollbar,
1010
setScrollbarWidth,
1111
mapToCssModules,
12+
omit
1213
} from './utils';
1314

1415
const propTypes = {
@@ -45,6 +46,8 @@ const propTypes = {
4546
modalTransitionLeaveTimeout: PropTypes.number,
4647
};
4748

49+
const propsToOmit = Object.keys(propTypes);
50+
4851
const defaultProps = {
4952
isOpen: false,
5053
autoFocus: true,
@@ -182,13 +185,16 @@ class Modal extends React.Component {
182185
}
183186

184187
renderModalDialog() {
188+
const attributes = omit(this.props, propsToOmit);
189+
185190
return (
186191
<div
187192
className={mapToCssModules(classNames('modal-dialog', this.props.className, {
188193
[`modal-${this.props.size}`]: this.props.size
189194
}), this.props.cssModule)}
190195
role="document"
191196
ref={(c) => (this._dialog = c)}
197+
{...attributes}
192198
>
193199
<div
194200
className={mapToCssModules(

src/__tests__/Modal.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ describe('Modal', () => {
9797
wrapper.unmount();
9898
});
9999

100+
it('should render with additional props if provided', () => {
101+
isOpen = true;
102+
const wrapper = mount(
103+
<Modal isOpen={isOpen} toggle={toggle} style={{ maxWidth: '95%' }}>
104+
Yo!
105+
</Modal>
106+
);
107+
108+
jasmine.clock().tick(300);
109+
expect(wrapper.children().length).toBe(0);
110+
expect(document.getElementsByClassName('modal-dialog').length).toBe(1);
111+
expect(document.getElementsByClassName('modal-dialog')[0].style.maxWidth).toBe('95%');
112+
wrapper.unmount();
113+
});
114+
100115
it('should render without fade transition if provided with fade={false}', () => {
101116
isOpen = true;
102117
const wrapper = mount(

0 commit comments

Comments
 (0)