Skip to content

Commit

Permalink
reset composer state when sidebar opens
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed May 26, 2022
1 parent 95e4723 commit 46b7aa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import EmojiPickerButton from '../../../components/EmojiPicker/EmojiPickerButton
import VirtualKeyboard from '../../../libs/VirtualKeyboard';
import canUseTouchScreen from '../../../libs/canUseTouchscreen';
import networkPropTypes from '../../../components/networkPropTypes';
import toggleReportActionComposeView from '../../../libs/toggleReportActionComposeView';

const propTypes = {
/** Beta features list */
Expand Down Expand Up @@ -159,6 +160,11 @@ class ReportActionCompose extends React.Component {
}

componentDidUpdate(prevProps) {
const sidebarOpened = !prevProps.isDrawerOpen && this.props.isDrawerOpen;
if (sidebarOpened) {
toggleReportActionComposeView(true, true);
}

// We want to focus or refocus the input when a modal has been closed and the underlying screen is focused.
// We avoid doing this on native platforms since the software keyboard popping
// open creates a jarring and broken UX.
Expand Down
6 changes: 3 additions & 3 deletions src/pages/home/report/ReportActionItemMessageEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ReportActionItemMessageEdit extends React.Component {
this.triggerSaveOrCancel = this.triggerSaveOrCancel.bind(this);
this.onSelectionChange = this.onSelectionChange.bind(this);
this.addEmojiToTextBox = this.addEmojiToTextBox.bind(this);
this.saveButtonID = 'saveButton';

const parser = new ExpensiMark();
const draftMessage = parser.htmlToMarkdown(this.props.draftMessage);
Expand Down Expand Up @@ -212,7 +213,7 @@ class ReportActionItemMessageEdit extends React.Component {
}}
onBlur={(event) => {
// Return to prevent re-render when save button is pressed which cancels the onPress event by re-rendering
if (lodashGet(event, 'nativeEvent.relatedTarget.id') === 'saveButton') {
if (lodashGet(event, 'nativeEvent.relatedTarget.id') === this.saveButtonID) {
return;
}

Expand Down Expand Up @@ -240,11 +241,10 @@ class ReportActionItemMessageEdit extends React.Component {
<Button
small
success
nativeID="saveButton"
nativeID={this.saveButtonID}
style={[styles.mr2]}
onPress={() => {
this.publishDraft();
toggleReportActionComposeView(true, VirtualKeyboard.shouldAssumeIsOpen());
}}
text={this.props.translate('common.saveChanges')}
/>
Expand Down

0 comments on commit 46b7aa7

Please sign in to comment.