Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions src/libs/ComposerUtils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import getNumberOfLines from './getNumberOfLines';
import updateNumberOfLines from './updateNumberOfLines';
import * as DeviceCapabilities from '../DeviceCapabilities';

/**
* Replace substring between selection with a text.
Expand All @@ -12,8 +13,21 @@ function insertText(text, selection, textToInsert) {
return text.slice(0, selection.start) + textToInsert + text.slice(selection.end, text.length);
}

/**
* Check whether we can skip trigger hotkeys on some specific devices.
* @param {Boolean} isSmallScreenWidth
* @param {Boolean} isKeyboardShown
* @returns {Boolean}
*/
function canSkipTriggerHotkeys(isSmallScreenWidth, isKeyboardShown) {
// Do not trigger actions for mobileWeb or native clients that have the keyboard open
// because for those devices, we want the return key to insert newlines rather than submit the form
return (isSmallScreenWidth && DeviceCapabilities.canUseTouchScreen()) || isKeyboardShown;
}

export {
getNumberOfLines,
updateNumberOfLines,
insertText,
canSkipTriggerHotkeys,
};
3 changes: 1 addition & 2 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,7 @@ class ReportActionCompose extends React.Component {
* @param {Object} e
*/
triggerHotkeyActions(e) {
// Do not trigger actions for mobileWeb or native clients that have the keyboard open because for those devices, we want the return key to insert newlines rather than submit the form
if (!e || this.props.isSmallScreenWidth || this.props.isKeyboardShown) {
if (!e || ComposerUtils.canSkipTriggerHotkeys(this.props.isSmallScreenWidth, this.props.isKeyboardShown)) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/report/ReportActionItemMessageEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ class ReportActionItemMessageEdit extends React.Component {
* @param {Event} e
*/
triggerSaveOrCancel(e) {
// Do not trigger actions for mobileWeb or native clients that have the keyboard open because for those devices, we want the return key to insert newlines rather than submit the form
if (!e || this.props.isSmallScreenWidth || this.props.isKeyboardShown) {
if (!e || ComposerUtils.canSkipTriggerHotkeys(this.props.isSmallScreenWidth, this.props.isKeyboardShown)) {
return;
}
if (e.key === 'Enter' && !e.shiftKey) {
Expand Down