PLT-4404 Replace calls to onInput with onChange to better support IE11 (#4315)

* Replace calls to onInput with onChange to better support IE11

* Replaced react-textarea-autosize with react-autosize-textarea
Этот коммит содержится в:
Harrison Healey
2016-10-25 10:11:34 -04:00
коммит произвёл GitHub
родитель f8182022b6
Коммит 0741d3be0a
9 изменённых файлов: 45 добавлений и 44 удалений

Просмотреть файл

@@ -1284,33 +1284,34 @@ limitations under the License.
--- ---
This product contains a modified portion of 'react-textarea-autosize', a drop-in replacement for the textarea component which automatically resizes textarea as content changes by Andrey Popp. This product contains a modified portion of 'react-autosize-textarea', a light replacement for built-in textarea component which automaticaly adjusts its height to match the content.
* HOMEPAGE: * HOMEPAGE:
* https://github.com/andreypopp/react-textarea-autosize * https://github.com/buildo/react-autosize-textarea
* LICENSE: * LICENSE:
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2013 Andrey Popp Copyright (c) 2016 buildo s.r.l.s.
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy
this software and associated documentation files (the "Software"), to deal in of this software and associated documentation files (the "Software"), to deal
the Software without restriction, including without limitation the rights to in the Software without restriction, including without limitation the rights
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
the Software, and to permit persons to whom the Software is furnished to do so, copies of the Software, and to permit persons to whom the Software is
subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--- ---

Просмотреть файл

@@ -23,7 +23,7 @@ export default class SwitchChannelModal extends React.Component {
constructor() { constructor() {
super(); super();
this.onInput = this.onInput.bind(this); this.onChange = this.onChange.bind(this);
this.onShow = this.onShow.bind(this); this.onShow = this.onShow.bind(this);
this.onHide = this.onHide.bind(this); this.onHide = this.onHide.bind(this);
this.onExited = this.onExited.bind(this); this.onExited = this.onExited.bind(this);
@@ -68,7 +68,7 @@ export default class SwitchChannelModal extends React.Component {
}); });
} }
onInput(e) { onChange(e) {
this.setState({text: e.target.value}); this.setState({text: e.target.value});
} }
@@ -152,7 +152,7 @@ export default class SwitchChannelModal extends React.Component {
ref='search' ref='search'
className='form-control focused' className='form-control focused'
type='input' type='input'
onInput={this.onInput} onChange={this.onChange}
value={this.state.text} value={this.state.text}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown}
listComponent={SuggestionList} listComponent={SuggestionList}

Просмотреть файл

@@ -35,7 +35,7 @@ export default class CreateComment extends React.Component {
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.commentMsgKeyPress = this.commentMsgKeyPress.bind(this); this.commentMsgKeyPress = this.commentMsgKeyPress.bind(this);
this.handleInput = this.handleInput.bind(this); this.handleChange = this.handleChange.bind(this);
this.handleKeyDown = this.handleKeyDown.bind(this); this.handleKeyDown = this.handleKeyDown.bind(this);
this.handleUploadClick = this.handleUploadClick.bind(this); this.handleUploadClick = this.handleUploadClick.bind(this);
this.handleUploadStart = this.handleUploadStart.bind(this); this.handleUploadStart = this.handleUploadStart.bind(this);
@@ -180,7 +180,7 @@ export default class CreateComment extends React.Component {
GlobalActions.emitLocalUserTypingEvent(this.props.channelId, this.props.rootId); GlobalActions.emitLocalUserTypingEvent(this.props.channelId, this.props.rootId);
} }
handleInput(e) { handleChange(e) {
const messageText = e.target.value; const messageText = e.target.value;
const draft = PostStore.getCommentDraft(this.props.rootId); const draft = PostStore.getCommentDraft(this.props.rootId);
@@ -393,7 +393,7 @@ export default class CreateComment extends React.Component {
> >
<div className='post-body__cell'> <div className='post-body__cell'>
<Textbox <Textbox
onInput={this.handleInput} onChange={this.handleChange}
onKeyPress={this.commentMsgKeyPress} onKeyPress={this.commentMsgKeyPress}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown}
messageText={this.state.messageText} messageText={this.state.messageText}

Просмотреть файл

@@ -43,7 +43,7 @@ export default class CreatePost extends React.Component {
this.getCurrentDraft = this.getCurrentDraft.bind(this); this.getCurrentDraft = this.getCurrentDraft.bind(this);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.postMsgKeyPress = this.postMsgKeyPress.bind(this); this.postMsgKeyPress = this.postMsgKeyPress.bind(this);
this.handleInput = this.handleInput.bind(this); this.handleChange = this.handleChange.bind(this);
this.handleUploadClick = this.handleUploadClick.bind(this); this.handleUploadClick = this.handleUploadClick.bind(this);
this.handleUploadStart = this.handleUploadStart.bind(this); this.handleUploadStart = this.handleUploadStart.bind(this);
this.handleFileUploadComplete = this.handleFileUploadComplete.bind(this); this.handleFileUploadComplete = this.handleFileUploadComplete.bind(this);
@@ -210,7 +210,7 @@ export default class CreatePost extends React.Component {
GlobalActions.emitLocalUserTypingEvent(this.state.channelId, ''); GlobalActions.emitLocalUserTypingEvent(this.state.channelId, '');
} }
handleInput(e) { handleChange(e) {
const messageText = e.target.value; const messageText = e.target.value;
this.setState({messageText}); this.setState({messageText});
@@ -512,7 +512,7 @@ export default class CreatePost extends React.Component {
<div className='post-create-body'> <div className='post-create-body'>
<div className='post-body__cell'> <div className='post-body__cell'>
<Textbox <Textbox
onInput={this.handleInput} onChange={this.handleChange}
onKeyPress={this.postMsgKeyPress} onKeyPress={this.postMsgKeyPress}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown}
messageText={this.state.messageText} messageText={this.state.messageText}

Просмотреть файл

@@ -31,7 +31,7 @@ export default class EditPostModal extends React.Component {
this.handleEditKeyPress = this.handleEditKeyPress.bind(this); this.handleEditKeyPress = this.handleEditKeyPress.bind(this);
this.handleEditPostEvent = this.handleEditPostEvent.bind(this); this.handleEditPostEvent = this.handleEditPostEvent.bind(this);
this.handleKeyDown = this.handleKeyDown.bind(this); this.handleKeyDown = this.handleKeyDown.bind(this);
this.handleInput = this.handleInput.bind(this); this.handleChange = this.handleChange.bind(this);
this.onPreferenceChange = this.onPreferenceChange.bind(this); this.onPreferenceChange = this.onPreferenceChange.bind(this);
this.onModalHidden = this.onModalHidden.bind(this); this.onModalHidden = this.onModalHidden.bind(this);
this.onModalShow = this.onModalShow.bind(this); this.onModalShow = this.onModalShow.bind(this);
@@ -89,7 +89,7 @@ export default class EditPostModal extends React.Component {
$('#edit_post').modal('hide'); $('#edit_post').modal('hide');
} }
handleInput(e) { handleChange(e) {
this.setState({ this.setState({
editText: e.target.value editText: e.target.value
}); });
@@ -230,7 +230,7 @@ export default class EditPostModal extends React.Component {
</div> </div>
<div className='edit-modal-body modal-body'> <div className='edit-modal-body modal-body'>
<Textbox <Textbox
onInput={this.handleInput} onChange={this.handleChange}
onKeyPress={this.handleEditKeyPress} onKeyPress={this.handleEditKeyPress}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown}
messageText={this.state.editText} messageText={this.state.editText}

Просмотреть файл

@@ -27,7 +27,7 @@ export default class SearchBar extends React.Component {
this.mounted = false; this.mounted = false;
this.onListenerChange = this.onListenerChange.bind(this); this.onListenerChange = this.onListenerChange.bind(this);
this.handleInput = this.handleInput.bind(this); this.handleChange = this.handleChange.bind(this);
this.handleUserFocus = this.handleUserFocus.bind(this); this.handleUserFocus = this.handleUserFocus.bind(this);
this.handleUserBlur = this.handleUserBlur.bind(this); this.handleUserBlur = this.handleUserBlur.bind(this);
this.performSearch = this.performSearch.bind(this); this.performSearch = this.performSearch.bind(this);
@@ -94,7 +94,7 @@ export default class SearchBar extends React.Component {
}); });
} }
handleInput(e) { handleChange(e) {
var term = e.target.value; var term = e.target.value;
SearchStore.storeSearchTerm(term); SearchStore.storeSearchTerm(term);
SearchStore.emitSearchTermChange(false); SearchStore.emitSearchTermChange(false);
@@ -188,7 +188,7 @@ export default class SearchBar extends React.Component {
value={this.state.searchTerm} value={this.state.searchTerm}
onFocus={this.handleUserFocus} onFocus={this.handleUserFocus}
onBlur={this.handleUserBlur} onBlur={this.handleUserBlur}
onInput={this.handleInput} onChange={this.handleChange}
listComponent={SearchSuggestionList} listComponent={SearchSuggestionList}
providers={this.suggestionProviders} providers={this.suggestionProviders}
type='search' type='search'

Просмотреть файл

@@ -9,7 +9,7 @@ import * as GlobalActions from 'actions/global_actions.jsx';
import SuggestionStore from 'stores/suggestion_store.jsx'; import SuggestionStore from 'stores/suggestion_store.jsx';
import * as Utils from 'utils/utils.jsx'; import * as Utils from 'utils/utils.jsx';
import TextareaAutosize from 'react-textarea-autosize'; import TextareaAutosize from 'react-autosize-textarea';
const KeyCodes = Constants.KeyCodes; const KeyCodes = Constants.KeyCodes;
@@ -22,7 +22,7 @@ export default class SuggestionBox extends React.Component {
this.handleDocumentClick = this.handleDocumentClick.bind(this); this.handleDocumentClick = this.handleDocumentClick.bind(this);
this.handleCompleteWord = this.handleCompleteWord.bind(this); this.handleCompleteWord = this.handleCompleteWord.bind(this);
this.handleInput = this.handleInput.bind(this); this.handleChange = this.handleChange.bind(this);
this.handleKeyDown = this.handleKeyDown.bind(this); this.handleKeyDown = this.handleKeyDown.bind(this);
this.handlePretextChanged = this.handlePretextChanged.bind(this); this.handlePretextChanged = this.handlePretextChanged.bind(this);
@@ -70,15 +70,15 @@ export default class SuggestionBox extends React.Component {
} }
} }
handleInput(e) { handleChange(e) {
const textbox = ReactDOM.findDOMNode(this.refs.textbox); const textbox = ReactDOM.findDOMNode(this.refs.textbox);
const caret = Utils.getCaretPosition(textbox); const caret = Utils.getCaretPosition(textbox);
const pretext = textbox.value.substring(0, caret); const pretext = textbox.value.substring(0, caret);
GlobalActions.emitSuggestionPretextChanged(this.suggestionId, pretext); GlobalActions.emitSuggestionPretextChanged(this.suggestionId, pretext);
if (this.props.onInput) { if (this.props.onChange) {
this.props.onInput(e); this.props.onChange(e);
} }
} }
@@ -103,14 +103,14 @@ export default class SuggestionBox extends React.Component {
this.refs.textbox.value = prefix + term + ' ' + suffix; this.refs.textbox.value = prefix + term + ' ' + suffix;
if (this.props.onInput) { if (this.props.onChange) {
// fake an input event to send back to parent components // fake an input event to send back to parent components
const e = { const e = {
target: this.refs.textbox target: this.refs.textbox
}; };
// don't call handleInput or we'll get into an event loop // don't call handleChange or we'll get into an event loop
this.props.onInput(e); this.props.onChange(e);
} }
textbox.focus(); textbox.focus();
@@ -157,7 +157,7 @@ export default class SuggestionBox extends React.Component {
ref='textbox' ref='textbox'
type='text' type='text'
{...this.props} {...this.props}
onInput={this.handleInput} onChange={this.handleChange}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown}
/> />
); );
@@ -167,7 +167,7 @@ export default class SuggestionBox extends React.Component {
ref='textbox' ref='textbox'
type='search' type='search'
{...this.props} {...this.props}
onInput={this.handleInput} onChange={this.handleChange}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown}
/> />
); );
@@ -177,7 +177,7 @@ export default class SuggestionBox extends React.Component {
id={this.suggestionId} id={this.suggestionId}
ref='textbox' ref='textbox'
{...this.props} {...this.props}
onInput={this.handleInput} onChange={this.handleChange}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown}
/> />
); );
@@ -226,6 +226,6 @@ SuggestionBox.propTypes = {
renderDividers: React.PropTypes.bool, renderDividers: React.PropTypes.bool,
// explicitly name any input event handlers we override and need to manually call // explicitly name any input event handlers we override and need to manually call
onInput: React.PropTypes.func, onChange: React.PropTypes.func,
onKeyDown: React.PropTypes.func onKeyDown: React.PropTypes.func
}; };

Просмотреть файл

@@ -206,7 +206,7 @@ export default class Textbox extends React.Component {
spellCheck='true' spellCheck='true'
maxLength={Constants.MAX_POST_LEN} maxLength={Constants.MAX_POST_LEN}
placeholder={this.props.createMessage} placeholder={this.props.createMessage}
onInput={this.props.onInput} onChange={this.props.onChange}
onKeyPress={this.handleKeyPress} onKeyPress={this.handleKeyPress}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown}
onHeightChange={this.handleHeightChange} onHeightChange={this.handleHeightChange}
@@ -251,7 +251,7 @@ Textbox.propTypes = {
id: React.PropTypes.string.isRequired, id: React.PropTypes.string.isRequired,
channelId: React.PropTypes.string, channelId: React.PropTypes.string,
messageText: React.PropTypes.string.isRequired, messageText: React.PropTypes.string.isRequired,
onInput: React.PropTypes.func.isRequired, onChange: React.PropTypes.func.isRequired,
onKeyPress: React.PropTypes.func.isRequired, onKeyPress: React.PropTypes.func.isRequired,
createMessage: React.PropTypes.string.isRequired, createMessage: React.PropTypes.string.isRequired,
onKeyDown: React.PropTypes.func, onKeyDown: React.PropTypes.func,

Просмотреть файл

@@ -24,13 +24,13 @@
"perfect-scrollbar": "0.6.12", "perfect-scrollbar": "0.6.12",
"react": "15.3.2", "react": "15.3.2",
"react-addons-pure-render-mixin": "15.3.2", "react-addons-pure-render-mixin": "15.3.2",
"react-autosize-textarea": "0.3.3",
"react-bootstrap": "0.30.3", "react-bootstrap": "0.30.3",
"react-custom-scrollbars": "4.0.0", "react-custom-scrollbars": "4.0.0",
"react-dom": "15.3.2", "react-dom": "15.3.2",
"react-intl": "2.1.5", "react-intl": "2.1.5",
"react-router": "2.8.1", "react-router": "2.8.1",
"react-select": "1.0.0-rc.2", "react-select": "1.0.0-rc.2",
"react-textarea-autosize": "4.0.5",
"superagent": "2.3.0", "superagent": "2.3.0",
"twemoji": "2.2.0", "twemoji": "2.2.0",
"velocity-animate": "1.2.3", "velocity-animate": "1.2.3",