From 3dc45578c25551f5eb60c9bc862bfa6b1b2dbd95 Mon Sep 17 00:00:00 2001 From: Terry Sahaidak Date: Thu, 4 May 2023 13:30:44 +0300 Subject: [PATCH] Fix ExceededCommentLength and address review feedback --- src/pages/home/report/ReportActionItem.js | 2 +- .../report/ReportActionItemMessageEdit.js | 177 +++++++++--------- 2 files changed, 90 insertions(+), 89 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 63374796afb7..944ab08220a7 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -240,7 +240,7 @@ class ReportActionItem extends Component { <> {children} {hasReactions && ( - + - - - ([styles.chatItemSubmitButton, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed))])} - nativeID={this.cancelButtonID} - onPress={this.deleteDraft} - hitSlop={{ - top: 3, right: 3, bottom: 3, left: 3, - }} - disabled={hasExceededMaxCommentLength} - > - {({hovered, pressed}) => ( - - )} - - - - - - { - this.textInput = el; - this.props.forwardedRef(el); - }} - nativeID={this.messageEditInput} - onChangeText={this.updateDraft} // Debounced saveDraftComment - onKeyPress={this.triggerSaveOrCancel} - value={this.state.draft} - maxLines={16} // This is the same that slack has - style={[styles.textInputCompose, styles.flex1, styles.bgTransparent]} - onFocus={() => { - this.setState({isFocused: true}); - ReportScrollManager.scrollToIndex({animated: true, index: this.props.index}, true); - toggleReportActionComposeView(false, this.props.isSmallScreenWidth); - }} - onBlur={(event) => { - this.setState({isFocused: false}); - const relatedTargetId = lodashGet(event, 'nativeEvent.relatedTarget.id'); - - // Return to prevent re-render when save/cancel button is pressed which cancels the onPress event by re-rendering - if (_.contains([this.saveButtonID, this.cancelButtonID, this.emojiButtonID], relatedTargetId)) { - return; - } - - if (this.messageEditInput === relatedTargetId) { - return; - } - openReportActionComposeViewWhenClosingMessageEdit(this.props.isSmallScreenWidth); - }} - selection={this.state.selection} - onSelectionChange={this.onSelectionChange} - /> - - - InteractionManager.runAfterInteractions(() => this.textInput.focus())} - onEmojiSelected={this.addEmojiToTextBox} - nativeID={this.emojiButtonID} - /> - - - - - + + + + ([styles.chatItemSubmitButton, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed))])} + nativeID={this.cancelButtonID} + onPress={this.deleteDraft} hitSlop={{ top: 3, right: 3, bottom: 3, left: 3, }} - nativeID={this.saveButtonID} - disabled={hasExceededMaxCommentLength} > - - + {({hovered, pressed}) => ( + + )} + - + + + { + this.textInput = el; + this.props.forwardedRef(el); + }} + nativeID={this.messageEditInput} + onChangeText={this.updateDraft} // Debounced saveDraftComment + onKeyPress={this.triggerSaveOrCancel} + value={this.state.draft} + maxLines={16} // This is the same that slack has + style={[styles.textInputCompose, styles.flex1, styles.bgTransparent]} + onFocus={() => { + this.setState({isFocused: true}); + ReportScrollManager.scrollToIndex({animated: true, index: this.props.index}, true); + toggleReportActionComposeView(false, this.props.isSmallScreenWidth); + }} + onBlur={(event) => { + this.setState({isFocused: false}); + const relatedTargetId = lodashGet(event, 'nativeEvent.relatedTarget.id'); + + // Return to prevent re-render when save/cancel button is pressed which cancels the onPress event by re-rendering + if (_.contains([this.saveButtonID, this.cancelButtonID, this.emojiButtonID], relatedTargetId)) { + return; + } + + if (this.messageEditInput === relatedTargetId) { + return; + } + openReportActionComposeViewWhenClosingMessageEdit(this.props.isSmallScreenWidth); + }} + selection={this.state.selection} + onSelectionChange={this.onSelectionChange} + /> + + + InteractionManager.runAfterInteractions(() => this.textInput.focus())} + onEmojiSelected={this.addEmojiToTextBox} + nativeID={this.emojiButtonID} + /> + + + + + + + + + + + - + ); } }