Skip to content

Commit

Permalink
feat(Modal): add ref to Modal (reactstrap#1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
illiteratewriter committed Jun 23, 2018
1 parent e6a1313 commit d2b7842
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/lib/Components/ModalsPage.js
Expand Up @@ -93,10 +93,11 @@ export default class ModalsPage extends React.Component {
// timeout is 150ms by default to match bootstrap
// see [Fade](/components/fade/) for more details
backdropTransition: PropTypes.shape(Fade.propTypes),
// modalTransition - controls modal transition
// modalTransition - controls modal transition
// timeout is 300ms by default to match bootstrap
// see [Fade](/components/fade/) for more details
modalTransition: PropTypes.shape(Fade.propTypes),
innerRef: PropTypes.object,
}`}
</PrismCode>
</pre>
Expand Down
4 changes: 3 additions & 1 deletion src/Fade.js
Expand Up @@ -15,6 +15,7 @@ const propTypes = {
baseClassActive: PropTypes.string,
className: PropTypes.string,
cssModule: PropTypes.object,
innerRef: PropTypes.object,
};

const defaultProps = {
Expand All @@ -37,6 +38,7 @@ function Fade(props) {
className,
cssModule,
children,
innerRef,
...otherProps
} = props;

Expand Down Expand Up @@ -64,7 +66,7 @@ function Fade(props) {
isActive && baseClassActive
), cssModule);
return (
<Tag className={classes} {...childProps}>
<Tag className={classes} {...childProps} ref={innerRef}>
{children}
</Tag>
);
Expand Down
3 changes: 3 additions & 0 deletions src/Modal.js
Expand Up @@ -48,6 +48,7 @@ const propTypes = {
]),
backdropTransition: FadePropTypes,
modalTransition: FadePropTypes,
innerRef: PropTypes.object,
};

const propsToOmit = Object.keys(propTypes);
Expand Down Expand Up @@ -260,6 +261,7 @@ class Modal extends React.Component {
role,
labelledBy,
external,
innerRef,
} = this.props;

const modalAttributes = {
Expand Down Expand Up @@ -297,6 +299,7 @@ class Modal extends React.Component {
onExited={this.onClosed}
cssModule={cssModule}
className={mapToCssModules(classNames('modal', modalClassName), cssModule)}
innerRef={innerRef}
>
{external}
{this.renderModalDialog()}
Expand Down

0 comments on commit d2b7842

Please sign in to comment.