diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-11-04 11:21:14 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-11-04 11:21:14 -0400 |
commit | e6f7a47c99075a39d862308659b904bfaf64a11a (patch) | |
tree | 863f6eb80a2367fb080437d9e037fca283e3c270 /webapp/components/edit_channel_purpose_modal.jsx | |
parent | dbdd719c51d061dfc327644d4b2ca89a0595b4f1 (diff) | |
download | chat-e6f7a47c99075a39d862308659b904bfaf64a11a.tar.gz chat-e6f7a47c99075a39d862308659b904bfaf64a11a.tar.bz2 chat-e6f7a47c99075a39d862308659b904bfaf64a11a.zip |
PLT-4507 Don't mount modals until opened to make resetting state automatic (#4358)
* Don't mount modals until opened to make resetting state automatic
* Move dimiss handler to be fired after modal exit animation complete
Diffstat (limited to 'webapp/components/edit_channel_purpose_modal.jsx')
-rw-r--r-- | webapp/components/edit_channel_purpose_modal.jsx | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/webapp/components/edit_channel_purpose_modal.jsx b/webapp/components/edit_channel_purpose_modal.jsx index 31d8e1bbd..bfb4d181a 100644 --- a/webapp/components/edit_channel_purpose_modal.jsx +++ b/webapp/components/edit_channel_purpose_modal.jsx @@ -1,17 +1,16 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import $ from 'jquery'; -import ReactDOM from 'react-dom'; +import PreferenceStore from 'stores/preference_store.jsx'; + import * as AsyncClient from 'utils/async_client.jsx'; import Client from 'client/web_client.jsx'; import Constants from 'utils/constants.jsx'; -import {FormattedMessage} from 'react-intl'; -import PreferenceStore from 'stores/preference_store.jsx'; -import {Modal} from 'react-bootstrap'; import * as Utils from 'utils/utils.jsx'; import React from 'react'; +import {Modal} from 'react-bootstrap'; +import {FormattedMessage} from 'react-intl'; export default class EditChannelPurposeModal extends React.Component { constructor(props) { @@ -26,30 +25,22 @@ export default class EditChannelPurposeModal extends React.Component { this.state = { serverError: '', + show: true, submitted: false }; } componentDidMount() { PreferenceStore.addChangeListener(this.onPreferenceChange); + Utils.placeCaretAtEnd(this.refs.purpose); } componentWillUnmount() { PreferenceStore.removeChangeListener(this.onPreferenceChange); } - componentDidUpdate() { - if (this.props.show) { - $(ReactDOM.findDOMNode(this.refs.purpose)).focus(); - } - } - handleHide() { - this.setState({serverError: '', submitted: false}); - - if (this.props.onModalDismissed) { - this.props.onModalDismissed(); - } + this.setState({show: false}); } onPreferenceChange() { @@ -75,7 +66,7 @@ export default class EditChannelPurposeModal extends React.Component { Client.updateChannelPurpose( this.props.channel.id, - ReactDOM.findDOMNode(this.refs.purpose).value.trim(), + this.refs.purpose.value.trim(), () => { AsyncClient.getChannel(this.props.channel.id); @@ -92,10 +83,6 @@ export default class EditChannelPurposeModal extends React.Component { } render() { - if (!this.props.show) { - return null; - } - let serverError = null; if (this.state.serverError) { serverError = ( @@ -145,8 +132,9 @@ export default class EditChannelPurposeModal extends React.Component { <Modal className='modal-edit-channel-purpose' ref='modal' - show={this.props.show} + show={this.state.show} onHide={this.handleHide} + onExited={this.props.onModalDismissed} > <Modal.Header closeButton={true}> <Modal.Title> @@ -202,7 +190,6 @@ export default class EditChannelPurposeModal extends React.Component { } EditChannelPurposeModal.propTypes = { - show: React.PropTypes.bool.isRequired, channel: React.PropTypes.object, onModalDismissed: React.PropTypes.func.isRequired }; |