Skip to content

Commit

Permalink
Merge pull request #48415 from rezkiy37/fix/47082-do-not-focus-composer
Browse files Browse the repository at this point in the history
Do not focus input after other interactions
  • Loading branch information
mountiny authored Sep 27, 2024
2 parents 70ed492 + 3555591 commit 05ca35c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/libs/willBlurTextInputOnTapOutside/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
import type WillBlurTextInputOnTapOutside from './types';

const willBlurTextInputOnTapOutside: WillBlurTextInputOnTapOutside = () => true;
const willBlurTextInputOnTapOutside: WillBlurTextInputOnTapOutside = () => !getIsNarrowLayout();

export default willBlurTextInputOnTapOutside;
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ type AttachmentPickerWithMenuItemsProps = {
onTriggerAttachmentPicker: () => void;

/** Called when cancelling the attachment picker */
onCanceledAttachmentPicker: () => void;
onCanceledAttachmentPicker?: () => void;

/** Called when the menu with the items is closed after it was open */
onMenuClosed: () => void;
onMenuClosed?: () => void;

/** Called when the add action button is pressed */
onAddActionPressed: () => void;
Expand Down Expand Up @@ -192,7 +192,7 @@ function AttachmentPickerWithMenuItems({

const onPopoverMenuClose = () => {
setMenuVisibility(false);
onMenuClosed();
onMenuClosed?.();
};

const prevIsFocused = usePrevious(isFocused);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ function ReportActionCompose({

const isKeyboardVisibleWhenShowingModalRef = useRef(false);
const isNextModalWillOpenRef = useRef(false);
const restoreKeyboardState = useCallback(() => {
if (!isKeyboardVisibleWhenShowingModalRef.current || isNextModalWillOpenRef.current) {
return;
}
focus();
isKeyboardVisibleWhenShowingModalRef.current = false;
}, []);

const containerRef = useRef<View>(null);
const measureContainer = useCallback(
Expand Down Expand Up @@ -263,8 +256,7 @@ function ReportActionCompose({
const onAttachmentPreviewClose = useCallback(() => {
updateShouldShowSuggestionMenuToFalse();
setIsAttachmentPreviewActive(false);
restoreKeyboardState();
}, [updateShouldShowSuggestionMenuToFalse, restoreKeyboardState]);
}, [updateShouldShowSuggestionMenuToFalse]);

/**
* Add a new comment to this chat
Expand Down Expand Up @@ -455,11 +447,6 @@ function ReportActionCompose({
isMenuVisible={isMenuVisible}
onTriggerAttachmentPicker={onTriggerAttachmentPicker}
raiseIsScrollLikelyLayoutTriggered={raiseIsScrollLikelyLayoutTriggered}
onCanceledAttachmentPicker={() => {
isNextModalWillOpenRef.current = false;
restoreKeyboardState();
}}
onMenuClosed={restoreKeyboardState}
onAddActionPressed={onAddActionPressed}
onItemSelected={onItemSelected}
actionButtonRef={actionButtonRef}
Expand Down

0 comments on commit 05ca35c

Please sign in to comment.