Skip to content

fix: Search is not opened on report page with CMD(ctrl) + K #60170

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

Merged
merged 2 commits into from
Apr 15, 2025
Merged
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
11 changes: 8 additions & 3 deletions src/components/Search/SearchRouter/SearchRouterContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React, {useContext, useMemo, useRef, useState} from 'react';
import type {AnimatedTextInputRef} from '@components/RNTextInput';
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
import * as Modal from '@userActions/Modal';
import {navigationRef} from '@libs/Navigation/Navigation';
import {close} from '@userActions/Modal';
import NAVIGATORS from '@src/NAVIGATORS';
import SCREENS from '@src/SCREENS';
import type ChildrenProps from '@src/types/utils/ChildrenProps';

type SearchRouterContext = {
Expand Down Expand Up @@ -31,7 +34,7 @@ function SearchRouterContextProvider({children}: ChildrenProps) {

const routerContext = useMemo(() => {
const openSearchRouter = () => {
Modal.close(
close(
() => {
setIsSearchRouterDisplayed(true);
searchRouterDisplayedRef.current = true;
Expand All @@ -49,7 +52,9 @@ function SearchRouterContextProvider({children}: ChildrenProps) {
// So we need a function that is based on ref to correctly open/close it
// When user is on `/search` page we focus the Input instead of showing router
const toggleSearch = () => {
const isUserOnSearchPage = isSearchTopmostFullScreenRoute();
const searchFullScreenRoutes = navigationRef.getRootState()?.routes.findLast((route) => route.name === NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR);
const lastRoute = searchFullScreenRoutes?.state?.routes?.at(-1);
const isUserOnSearchPage = isSearchTopmostFullScreenRoute() && lastRoute?.name === SCREENS.SEARCH.ROOT;

if (isUserOnSearchPage && searchPageInputRef.current) {
if (searchPageInputRef.current.isFocused()) {
Expand Down