From cdc45d7b2ff5bdb7b7c43a2ece692de0f18fb60d Mon Sep 17 00:00:00 2001 From: mkhutornyi Date: Thu, 5 Oct 2023 20:17:24 +0100 Subject: [PATCH] prevent focusing on composer while popover is open --- src/components/BaseMiniContextMenuItem.js | 6 ++++++ src/components/LHNOptionsList/OptionRowLHN.js | 5 +++-- src/components/Reactions/AddReactionBubble.js | 11 +++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/BaseMiniContextMenuItem.js b/src/components/BaseMiniContextMenuItem.js index 0e9085b54c17..c5c0892324c3 100644 --- a/src/components/BaseMiniContextMenuItem.js +++ b/src/components/BaseMiniContextMenuItem.js @@ -61,6 +61,12 @@ function BaseMiniContextMenuItem(props) { return; } + // Allow text input blur on right click + if (!e || e.button === 2) { + return; + } + + // Prevent text input blur on left click e.preventDefault(); }} accessibilityLabel={props.tooltipText} diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index fb6fd59870a0..a5ad8a6b707d 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -171,11 +171,12 @@ function OptionRowLHN(props) { props.onSelectRow(optionItem, popoverAnchor); }} onMouseDown={(e) => { - if (!e) { + // Allow composer blur on right click + if (!e || e.button === 2) { return; } - // Prevent losing Composer focus + // Prevent composer blur on left click e.preventDefault(); }} onSecondaryInteraction={(e) => showPopover(e)} diff --git a/src/components/Reactions/AddReactionBubble.js b/src/components/Reactions/AddReactionBubble.js index 0315c63aabf1..656188559334 100644 --- a/src/components/Reactions/AddReactionBubble.js +++ b/src/components/Reactions/AddReactionBubble.js @@ -88,8 +88,15 @@ function AddReactionBubble(props) { ref={ref} style={({hovered, pressed}) => [styles.emojiReactionBubble, styles.userSelectNone, StyleUtils.getEmojiReactionBubbleStyle(hovered || pressed, false, props.isContextMenu)]} onPress={Session.checkIfActionIsAllowed(onPress)} - // Prevent text input blur when Add reaction is clicked - onMouseDown={(e) => e.preventDefault()} + onMouseDown={(e) => { + // Allow text input blur when Add reaction is right clicked + if (!e || e.button === 2) { + return; + } + + // Prevent text input blur when Add reaction is left clicked + e.preventDefault(); + }} accessibilityLabel={props.translate('emojiReactions.addReactionTooltip')} accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} // disable dimming