Skip to content

Commit

Permalink
Merge pull request Expensify#33483 from bernhardoj/fix/32970-don't-fo…
Browse files Browse the repository at this point in the history
…cus-if-popover-visible

Fix composer is focused after opening another popover
  • Loading branch information
jasperhuangg authored Jan 2, 2024
2 parents fe49e4f + 7c64b0f commit cb4fc64
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {findNodeHandle, InteractionManager, NativeModules, View} from 'react-nat
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import Composer from '@components/Composer';
import {PopoverContext} from '@components/PopoverProvider';
import withKeyboardState from '@components/withKeyboardState';
import useDebounce from '@hooks/useDebounce';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -106,6 +107,7 @@ function ComposerWithSuggestions({
// For testing
children,
}) {
const {isOpen: isPopoverOpen} = React.useContext(PopoverContext);
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand Down Expand Up @@ -427,9 +429,15 @@ function ComposerWithSuggestions({
* @param {Boolean} [shouldDelay=false] Impose delay before focusing the composer
* @memberof ReportActionCompose
*/
const focus = useCallback((shouldDelay = false) => {
focusComposerWithDelay(textInputRef.current)(shouldDelay);
}, []);
const focus = useCallback(
(shouldDelay = false) => {
if (isPopoverOpen) {
return;
}
focusComposerWithDelay(textInputRef.current)(shouldDelay);
},
[isPopoverOpen],
);

const setUpComposeFocusManager = useCallback(() => {
// This callback is used in the contextMenuActions to manage giving focus back to the compose input.
Expand Down

0 comments on commit cb4fc64

Please sign in to comment.