-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix: Composer does not refocus when click the same chat #24360
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
Changes from all 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'; | ||
|
|
@@ -81,6 +81,10 @@ function SidebarLinksData({isFocused, allReportActions, betas, chatReports, curr | |
| return reportIDsRef.current || []; | ||
| }, [allReportActions, betas, chatReports, currentReportID, policies, priorityMode, isLoading]); | ||
|
|
||
| const currentReportIDRef = useRef(currentReportID); | ||
| currentReportIDRef.current = currentReportID; | ||
|
Contributor
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. Is this value assignment needed? currentReportID is set on the line above as the initial value
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. Without that assignment, the ref would not be updated when |
||
| const isActiveReport = useCallback((reportID) => currentReportIDRef.current === reportID, []); | ||
|
Comment on lines
+84
to
+86
Collaborator
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. Can't we simplify the block like this? const isActiveReport = useCallback((reportID) => currentReportID === reportID, [currentReportID]);
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. I have mentioned in my proposal:
|
||
|
|
||
| return ( | ||
| <View | ||
| accessibilityElementsHidden={!isFocused} | ||
|
|
@@ -94,6 +98,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
currentReportIDis set toundefined. But asprevCurrentReportIDis saved in a ref, we cannot update the ref toundefinedwhich leads toprevCurrentReportIDunchanged 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.