Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/pages/home/report/ReportActionItemMessageEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import EmojiPickerButton from '../../../components/EmojiPicker/EmojiPickerButton
import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu';
import VirtualKeyboard from '../../../libs/VirtualKeyboard';
import reportPropTypes from '../../reportPropTypes';
import ExceededCommentLength from '../../../components/ExceededCommentLength';
import CONST from '../../../CONST';

const propTypes = {
/** All the data of the action */
Expand Down Expand Up @@ -131,6 +133,11 @@ class ReportActionItemMessageEdit extends React.Component {
* the new content.
*/
publishDraft() {
// Do nothing if draft exceed the character limit
if (this.state.draft.length > CONST.MAX_COMMENT_LENGTH) {
return;
}

// To prevent re-mount after user saves edit before debounce duration (example: within 1 second), we cancel
// debounce here.
this.debouncedSaveDraft.cancel();
Expand Down Expand Up @@ -186,9 +193,10 @@ class ReportActionItemMessageEdit extends React.Component {
}

render() {
const hasExceededMaxCommentLength = this.state.draft.length > CONST.MAX_COMMENT_LENGTH;
return (
<View style={styles.chatItemMessage}>
<View style={[styles.chatItemComposeBox, styles.flexRow, styles.chatItemComposeBoxColor]}>
<View style={[styles.chatItemComposeBox, styles.flexRow, styles.chatItemComposeBoxColor, hasExceededMaxCommentLength && styles.borderColorDanger]}>
<Composer
multiline
ref={(el) => {
Expand Down Expand Up @@ -235,11 +243,13 @@ class ReportActionItemMessageEdit extends React.Component {
<Button
small
success
isDisabled={hasExceededMaxCommentLength}
nativeID={this.saveButtonID}
style={[styles.mr2]}
onPress={this.publishDraft}
text={this.props.translate('common.saveChanges')}
/>
<ExceededCommentLength commentLength={this.state.draft.length} />
</View>
</View>
);
Expand Down