Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't focus on composer when open right modal #27155

Merged
merged 7 commits into from
Sep 13, 2023
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
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();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this to be the last function call?

Copy link
Contributor Author

@s-alves10 s-alves10 Sep 12, 2023

Choose a reason for hiding this comment

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

We need to overwrite isKeyboardVisibleWhenShowingModalRef.current value in triggerAttachmentPicker function when selecting Add attachment.
I think this is the ideal position this call should be placed at.
Is there any specific reason for moving?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you are right here.


// 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 @@ -322,11 +322,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
Loading