Skip to content

Commit

Permalink
Merge pull request #27155 from s-alves10/fix/issue-26489
Browse files Browse the repository at this point in the history
fix: don't focus on composer when open right modal
  • Loading branch information
youssef-lr authored Sep 13, 2023
2 parents da94df6 + 0d3f709 commit 6b7ee90
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ const propTypes = {
/** Called when the add action button is pressed */
onAddActionPressed: PropTypes.func.isRequired,

/** Called when the menu item is selected */
onItemSelected: PropTypes.func.isRequired,

/** A ref for the add action button */
actionButtonRef: PropTypes.shape({
// eslint-disable-next-line react/forbid-prop-types
Expand Down Expand Up @@ -111,6 +114,7 @@ function AttachmentPickerWithMenuItems({
onCanceledAttachmentPicker,
onMenuClosed,
onAddActionPressed,
onItemSelected,
actionButtonRef,
}) {
const {translate} = useLocalize();
Expand Down Expand Up @@ -257,6 +261,7 @@ function AttachmentPickerWithMenuItems({
onClose={onPopoverMenuClose}
onItemSelected={(item, index) => {
setMenuVisibility(false);
onItemSelected();

// In order for the file picker to open dynamically, the click
// function must be called from within a event handler that was initiated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ function ComposerWithSuggestions({
suggestionsRef.current.updateShouldShowSuggestionMenuToFalse(false);
}, [suggestionsRef]);

const setShouldBlockSuggestionCalc = useCallback(() => {
const setShouldBlockSuggestionCalcToFalse = useCallback(() => {
if (!suggestionsRef.current) {
return false;
}
return suggestionsRef.current.setShouldBlockSuggestionCalc(true);
return suggestionsRef.current.setShouldBlockSuggestionCalc(false);
}, [suggestionsRef]);

/**
Expand Down Expand Up @@ -472,7 +472,7 @@ function ComposerWithSuggestions({
maxLines={maxComposerLines}
onFocus={onFocus}
onBlur={onBlur}
onClick={setShouldBlockSuggestionCalc}
onClick={setShouldBlockSuggestionCalcToFalse}
onPasteFile={displayFileInModal}
shouldClear={textInputShouldClear}
onClear={() => setTextInputShouldClear(false)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const propTypes = {
};

const defaultProps = {
modal: {},
report: {},
blockedFromConcierge: {},
personalDetails: {},
Expand Down Expand Up @@ -205,6 +204,10 @@ function ReportActionCompose({
composerRef.current.blur();
}, []);

const onItemSelected = useCallback(() => {
isKeyboardVisibleWhenShowingModalRef.current = false;
}, []);

const updateShouldShowSuggestionMenuToFalse = useCallback(() => {
if (!suggestionsRef.current) {
return;
Expand Down Expand Up @@ -271,6 +274,7 @@ function ReportActionCompose({
suggestionsRef.current.setShouldBlockSuggestionCalc(true);
}
isNextModalWillOpenRef.current = true;
isKeyboardVisibleWhenShowingModalRef.current = true;
}, []);

const onBlur = useCallback((e) => {
Expand Down Expand Up @@ -358,6 +362,7 @@ function ReportActionCompose({
onCanceledAttachmentPicker={restoreKeyboardState}
onMenuClosed={restoreKeyboardState}
onAddActionPressed={onAddActionPressed}
onItemSelected={onItemSelected}
actionButtonRef={actionButtonRef}
/>
<ComposerWithSuggestions
Expand Down

0 comments on commit 6b7ee90

Please sign in to comment.