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
11 changes: 10 additions & 1 deletion src/components/BaseMiniContextMenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import getButtonState from '../libs/getButtonState';
import variables from '../styles/variables';
import Tooltip from './Tooltip';
import PressableWithoutFeedback from './Pressable/PressableWithoutFeedback';
import ReportActionComposeFocusManager from '../libs/ReportActionComposeFocusManager';
import DomUtils from '../libs/DomUtils';

const propTypes = {
/**
Expand Down Expand Up @@ -53,7 +55,14 @@ function BaseMiniContextMenuItem(props) {
<PressableWithoutFeedback
ref={props.innerRef}
onPress={props.onPress}
onMouseDown={(e) => e.preventDefault()}
onMouseDown={(e) => {
if (!ReportActionComposeFocusManager.isFocused() && !ReportActionComposeFocusManager.isEditFocused()) {
DomUtils.getActiveElement().blur();
return;
}

e.preventDefault();
}}
accessibilityLabel={props.tooltipText}
style={({hovered, pressed}) => [
styles.reportActionContextMenuMiniButton,
Expand Down
10 changes: 10 additions & 0 deletions src/libs/ReportActionComposeFocusManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {TextInput} from 'react-native';
type FocusCallback = () => void;

const composerRef = React.createRef<TextInput>();
const editComposerRef = React.createRef<TextInput>();
// There are two types of composer: general composer (edit composer) and main composer.
// The general composer callback will take priority if it exists.
let focusCallback: FocusCallback | null = null;
Expand Down Expand Up @@ -57,10 +58,19 @@ function isFocused(): boolean {
return !!composerRef.current?.isFocused();
}

/**
* Exposes the current focus state of the edit message composer.
*/
function isEditFocused(): boolean {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment for this function

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

return !!editComposerRef.current?.isFocused();
}

export default {
composerRef,
onComposerFocus,
focus,
clear,
isFocused,
editComposerRef,
isEditFocused,
};
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItemMessageEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ function ReportActionItemMessageEdit(props) {
<Composer
multiline
ref={(el) => {
ReportActionComposeFocusManager.editComposerRef.current = el;
textInputRef.current = el;
// eslint-disable-next-line no-param-reassign
props.forwardedRef.current = el;
Expand Down