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 - Search - App redirects to DM when submitting expense in Search after deleting expense #54109

Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 17 additions & 0 deletions src/libs/Navigation/isReportScreenTopmostCentralPane.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import SCREENS from '@src/SCREENS';
import getTopmostCentralPaneRoute from './getTopmostCentralPaneRoute';
import {navigationRef} from './Navigation';
import type {RootStackParamList, State} from './types';

const isReportScreenTopmostCentralPane = (): boolean => {
const rootState = navigationRef.getRootState() as State<RootStackParamList>;

if (!rootState) {
return false;
}

const topmostCentralPaneRoute = getTopmostCentralPaneRoute(rootState);
return topmostCentralPaneRoute?.name === SCREENS.REPORT;
};

export default isReportScreenTopmostCentralPane;
10 changes: 4 additions & 6 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import DateUtils from '@libs/DateUtils';
import isReportScreenTopmostCentralPane from '@libs/Navigation/isReportScreenTopmostCentralPane';
import isSearchTopmostCentralPane from '@libs/Navigation/isSearchTopmostCentralPane';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
Expand Down Expand Up @@ -157,7 +158,7 @@ function ReportActionsList({
const styles = useThemeStyles();
const {translate} = useLocalize();
const {windowHeight} = useWindowDimensions();
const {isInNarrowPaneModal, shouldUseNarrowLayout} = useResponsiveLayout();
const {shouldUseNarrowLayout} = useResponsiveLayout();

const {preferredLocale} = useLocalize();
const {isOffline, lastOfflineAt, lastOnlineAt} = useNetworkWithOfflineStatus();
Expand Down Expand Up @@ -417,19 +418,16 @@ function ReportActionsList({
(isFromCurrentUser: boolean) => {
// If a new comment is added and it's from the current user scroll to the bottom otherwise leave the user positioned where
// they are now in the list.
if (!isFromCurrentUser) {
if (!isFromCurrentUser || !isReportScreenTopmostCentralPane()) {
return;
}
if (!hasNewestReportActionRef.current) {
if (isInNarrowPaneModal) {
return;
}
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID));
return;
}
InteractionManager.runAfterInteractions(() => reportScrollManager.scrollToBottom());
},
[isInNarrowPaneModal, reportScrollManager, report.reportID],
[reportScrollManager, report.reportID],
);
useEffect(() => {
// Why are we doing this, when in the cleanup of the useEffect we are already calling the unsubscribe function?
Expand Down
Loading