From b796960a2514a2eb5ae900436806f343dbddf50f Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 2 Aug 2017 12:29:09 -0400 Subject: PLT-7204 Fixed markdown preview (#6997) * PLT-7204 Fixed markdown preview * Updated style of Textbox component --- webapp/components/textbox.jsx | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/webapp/components/textbox.jsx b/webapp/components/textbox.jsx index 3db87d106..3e62d98bc 100644 --- a/webapp/components/textbox.jsx +++ b/webapp/components/textbox.jsx @@ -50,16 +50,6 @@ export default class Textbox extends React.Component { constructor(props) { super(props); - this.focus = this.focus.bind(this); - this.recalculateSize = this.recalculateSize.bind(this); - this.onReceivedError = this.onReceivedError.bind(this); - this.handleKeyPress = this.handleKeyPress.bind(this); - this.handleKeyDown = this.handleKeyDown.bind(this); - this.handleBlur = this.handleBlur.bind(this); - this.handleHeightChange = this.handleHeightChange.bind(this); - this.showPreview = this.showPreview.bind(this); - this.handleChange = this.handleChange.bind(this); - this.state = { connection: '' }; @@ -86,7 +76,7 @@ export default class Textbox extends React.Component { ErrorStore.removeChangeListener(this.onReceivedError); } - onReceivedError() { + onReceivedError = () => { const errorCount = ErrorStore.getConnectionErrorCount(); if (errorCount > 1) { @@ -96,12 +86,12 @@ export default class Textbox extends React.Component { } } - handleChange(e) { + handleChange = (e) => { this.checkMessageLength(e.target.value); this.props.onChange(e); } - checkMessageLength(message) { + checkMessageLength = (message) => { if (this.props.handlePostError) { if (message.length > Constants.CHARACTER_LIMIT) { const errorMessage = ( @@ -120,23 +110,19 @@ export default class Textbox extends React.Component { } } - handleKeyPress(e) { - this.props.onKeyPress(e); - } - - handleKeyDown(e) { + handleKeyDown = (e) => { if (this.props.onKeyDown) { this.props.onKeyDown(e); } } - handleBlur(e) { + handleBlur = (e) => { if (this.props.onBlur) { this.props.onBlur(e); } } - handleHeightChange(height, maxHeight) { + handleHeightChange = (height, maxHeight) => { const wrapper = $(this.refs.wrapper); // Move over attachment icon to compensate for the scrollbar @@ -147,26 +133,26 @@ export default class Textbox extends React.Component { } } - focus() { + focus = () => { const textbox = this.refs.message.getTextbox(); textbox.focus(); Utils.placeCaretAtEnd(textbox); } - recalculateSize() { + recalculateSize = () => { this.refs.message.recalculateSize(); } - showPreview(e) { + togglePreview = (e) => { e.preventDefault(); e.target.blur(); this.setState((prevState) => { - return {preview: prevState.preview}; + return {preview: !prevState.preview}; }); } - hidePreview() { + hidePreview = () => { this.setState({preview: false}); } @@ -205,11 +191,11 @@ export default class Textbox extends React.Component { if (Utils.isFeatureEnabled(PreReleaseFeatures.MARKDOWN_PREVIEW)) { previewLink = ( {this.state.preview ? ( - editHeader + editHeader ) : (