diff options
author | Corey Hulen <corey@hulen.com> | 2015-11-23 10:22:55 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-11-23 10:22:55 -0800 |
commit | d42a567bab3cd306caf0a42bed804c26222a46da (patch) | |
tree | 3099b4d08323315985c547367349fc337971cbbe /web/react/components/toggle_modal_button.jsx | |
parent | c03a9859838e3492b50e71383587b98231408b7b (diff) | |
parent | 388dc6c89c62133c3c5fd1c3bb5ec0327cf5be6d (diff) | |
download | chat-d42a567bab3cd306caf0a42bed804c26222a46da.tar.gz chat-d42a567bab3cd306caf0a42bed804c26222a46da.tar.bz2 chat-d42a567bab3cd306caf0a42bed804c26222a46da.zip |
Merge pull request #1485 from hmhealey/plt1151
PLT-1151 Refactor more modals to React-Bootstrap
Diffstat (limited to 'web/react/components/toggle_modal_button.jsx')
-rw-r--r-- | web/react/components/toggle_modal_button.jsx | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/web/react/components/toggle_modal_button.jsx b/web/react/components/toggle_modal_button.jsx index eae4a024d..ce8ff3f60 100644 --- a/web/react/components/toggle_modal_button.jsx +++ b/web/react/components/toggle_modal_button.jsx @@ -22,7 +22,17 @@ export default class ModalToggleButton extends React.Component { } render() { - const {children, dialogType, dialogProps, ...props} = this.props; //eslint-disable-line no-redeclare + const {children, dialogType, dialogProps, onClick, ...props} = this.props; // eslint-disable-line no-redeclare + + // allow callers to provide an onClick which will be called before the modal is shown + let clickHandler = this.show; + if (onClick) { + clickHandler = () => { + onClick(); + + this.show(); + }; + } // this assumes that all modals will have a show property and an onHide event const dialog = React.createElement(this.props.dialogType, Object.assign({}, dialogProps, { @@ -42,7 +52,7 @@ export default class ModalToggleButton extends React.Component { <a {...props} href='#' - onClick={this.show} + onClick={clickHandler} > {children} {dialog} @@ -54,7 +64,8 @@ export default class ModalToggleButton extends React.Component { ModalToggleButton.propTypes = { children: React.PropTypes.node.isRequired, dialogType: React.PropTypes.func.isRequired, - dialogProps: React.PropTypes.object + dialogProps: React.PropTypes.object, + onClick: React.PropTypes.func }; ModalToggleButton.defaultProps = { |