-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: Composer does not refocus when click the same chat #24360
Changes from 4 commits
2927390
adb010e
67e5169
fe9034b
923d512
bc0b9df
ac5f2dc
cbbc747
cf5e3ca
e8378ed
cb03fc8
4a671f7
d841942
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||||||||
import React, {useMemo, useRef} from 'react'; | ||||||||||||
import React, {useCallback, useMemo, useRef} from 'react'; | ||||||||||||
import _ from 'underscore'; | ||||||||||||
import {deepEqual} from 'fast-equals'; | ||||||||||||
import {withOnyx} from 'react-native-onyx'; | ||||||||||||
|
@@ -15,6 +15,7 @@ import CONST from '../../../CONST'; | |||||||||||
import useLocalize from '../../../hooks/useLocalize'; | ||||||||||||
import styles from '../../../styles/styles'; | ||||||||||||
import withNavigationFocus from '../../../components/withNavigationFocus'; | ||||||||||||
import usePrevious from '../../../hooks/usePrevious'; | ||||||||||||
|
||||||||||||
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. LINT |
||||||||||||
const propTypes = { | ||||||||||||
...basePropTypes, | ||||||||||||
|
@@ -75,6 +76,9 @@ function SidebarLinksData({isFocused, allReportActions, betas, chatReports, curr | |||||||||||
return reportIDs; | ||||||||||||
}, [allReportActions, betas, chatReports, currentReportID, policies, priorityMode]); | ||||||||||||
|
||||||||||||
const prevCurrentReportID = usePrevious(currentReportID); | ||||||||||||
const isActiveReport = useCallback((reportID) => prevCurrentReportID === reportID, [prevCurrentReportID]); | ||||||||||||
|
||||||||||||
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. Sorry, I know I proposed using So instead you might want to consider the following code:
Suggested change
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. Thanks a lot! I agree. |
||||||||||||
const isLoading = _.isEmpty(chatReports) || isPersonalDetailsLoading; | ||||||||||||
|
||||||||||||
return ( | ||||||||||||
|
@@ -90,6 +94,7 @@ function SidebarLinksData({isFocused, allReportActions, betas, chatReports, curr | |||||||||||
isSmallScreenWidth={isSmallScreenWidth} | ||||||||||||
priorityMode={priorityMode} | ||||||||||||
// Data props: | ||||||||||||
isActiveReport={isActiveReport} | ||||||||||||
isLoading={isLoading} | ||||||||||||
optionListItems={optionListItems} | ||||||||||||
/> | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On small screen devices, when we navigate from report screen back to LHN, the
currentReportID
is set toundefined
. But asprevCurrentReportID
is saved in a ref, we cannot update the ref toundefined
which leads toprevCurrentReportID
unchanged and thus cannot navigate back to that same report again.Also, the expected behavior only works on large screen devices so I added this check.