-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix: Focus jumps to Concierge Anywhere (SidePanel) when switching chats in the Inbox #86658
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
base: main
Are you sure you want to change the base?
Changes from all commits
2a74a48
0184417
f18fe2d
194f72d
9b41578
a6d64be
e6cbf3c
4cca863
181d589
72f8675
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import Composer from '@components/Composer'; | |
| import type {CustomSelectionChangeEvent, TextSelection} from '@components/Composer/types'; | ||
| import {useWideRHPState} from '@components/WideRHPContextProvider'; | ||
| import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; | ||
| import useIsInSidePanel from '@hooks/useIsInSidePanel'; | ||
| import useKeyboardState from '@hooks/useKeyboardState'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
|
|
@@ -263,6 +264,7 @@ function ComposerWithSuggestions({ | |
| const mobileInputScrollPosition = useRef(0); | ||
| const cursorPositionValue = useSharedValue({x: 0, y: 0}); | ||
| const tag = useSharedValue(-1); | ||
| const isInSidePanel = useIsInSidePanel(); | ||
| const [draftComment = ''] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`); | ||
| const [value, setValue] = useState(() => { | ||
| if (draftComment) { | ||
|
|
@@ -683,21 +685,33 @@ function ComposerWithSuggestions({ | |
| }; | ||
| }, [focus, route.key, shouldAutoFocus, shouldDelayAutoFocus]); | ||
|
|
||
| /** | ||
| * Tracks whether there is a composer input inside the side panel on the screen. | ||
| */ | ||
| const handleSidePanelFocus = useCallback(() => { | ||
| if (!isInSidePanel) { | ||
| ReportActionComposeFocusManager.sidePanelComposerRef.current = null; | ||
| } else { | ||
| ReportActionComposeFocusManager.sidePanelComposerRef.current = textInputRef.current; | ||
| } | ||
| }, [isInSidePanel]); | ||
|
|
||
| /** | ||
| * Set focus callback | ||
| * @param shouldTakeOverFocus - Whether this composer should gain focus priority | ||
| */ | ||
| const setUpComposeFocusManager = useCallback( | ||
| (shouldTakeOverFocus = false) => { | ||
| ReportActionComposeFocusManager.onComposerFocus((shouldFocusForNonBlurInputOnTapOutside = false) => { | ||
| handleSidePanelFocus(); | ||
| if ((!willBlurTextInputOnTapOutside && !shouldFocusForNonBlurInputOnTapOutside) || !isFocused || !isSidePanelHiddenOrLargeScreen) { | ||
| return; | ||
| } | ||
|
|
||
| focus(true); | ||
| }, shouldTakeOverFocus); | ||
| }, | ||
| [focus, isFocused, isSidePanelHiddenOrLargeScreen], | ||
| [focus, isFocused, isSidePanelHiddenOrLargeScreen, handleSidePanelFocus], | ||
| ); | ||
|
|
||
| /** | ||
|
|
@@ -797,6 +811,11 @@ function ComposerWithSuggestions({ | |
| return; | ||
| } | ||
|
|
||
| // Do not focus side panels composer if it wasn't focused before | ||
| if (isInSidePanel && !ReportActionComposeFocusManager.sidePanelComposerRef.current) { | ||
| return; | ||
| } | ||
|
|
||
| // Do not focus the composer if the Side Panel is visible | ||
| if (!isSidePanelHiddenOrLargeScreen) { | ||
| return; | ||
|
|
@@ -814,7 +833,7 @@ function ComposerWithSuggestions({ | |
| return; | ||
| } | ||
| focus(true); | ||
| }, [focus, prevIsFocused, editFocused, prevIsModalVisible, isFocused, modal?.isVisible, isNextModalWillOpenRef, shouldAutoFocus, isSidePanelHiddenOrLargeScreen]); | ||
| }, [focus, prevIsFocused, editFocused, prevIsModalVisible, isFocused, modal?.isVisible, isNextModalWillOpenRef, shouldAutoFocus, isSidePanelHiddenOrLargeScreen, isInSidePanel]); | ||
|
|
||
| useEffect(() => { | ||
| // Scrolls the composer to the bottom and sets the selection to the end, so that longer drafts are easier to edit | ||
|
|
@@ -913,10 +932,10 @@ function ComposerWithSuggestions({ | |
| ); | ||
|
|
||
| const handleFocus = useCallback(() => { | ||
| // The last composer that had focus should re-gain focus | ||
| setUpComposeFocusManager(true); | ||
| handleSidePanelFocus(); | ||
| setUpComposeFocusManager(!isInSidePanel); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is intentional, stops side panel from stealing focus when we switch reports There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Registering the main composer with Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was true before (always priority) so I think it's ok There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
New in this commit, side-panel focus now always registers as non-priority via Useful? React with 👍 / 👎. |
||
| onFocus(); | ||
| }, [onFocus, setUpComposeFocusManager]); | ||
| }, [onFocus, setUpComposeFocusManager, handleSidePanelFocus, isInSidePanel]); | ||
|
|
||
| // When using the suggestions box (Suggestions) we need to imperatively | ||
| // set the cursor to the end of the suggestion/mention after it's selected. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.