Skip to content

Commit

Permalink
fix: 🐛 searchBox hidden when offline
Browse files Browse the repository at this point in the history
searchBox hidden when offline
  • Loading branch information
oguzkaganeren committed Jan 12, 2023
1 parent da04461 commit ae2ebe9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/common/Search/SearchComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
} from '@chakra-ui/react';
import { SearchIcon } from '@chakra-ui/icons';
import { useTranslation } from 'react-i18next';
import { useRecoilValue } from 'recoil';
import SearchModelComponent from './SearchModelComponent';
import { connectionState } from '../../../stores/ConnectionStore';

const ACTION_KEY_DEFAULT = ['Ctrl', 'Control'];
const ACTION_KEY_APPLE = ['⌘', 'Command'];
Expand All @@ -21,6 +23,7 @@ interface SearchProps {
}
const SearchComponent = (props: SearchProps) => {
const { isForPackage } = props;
const isOnline = useRecoilValue(connectionState);
const searchModal = React.useRef<UseDisclosureReturn | null>(null);
const [actionKey, setActionKey] = React.useState(ACTION_KEY_APPLE);
const { t } = useTranslation();
Expand All @@ -44,8 +47,11 @@ const SearchComponent = (props: SearchProps) => {
});

return (
<Flex>
<SearchModelComponent id={isForPackage ? 'package' : 'anything'} ref={searchModal} />
<Flex hidden={!isOnline}>
<SearchModelComponent
id={isForPackage ? 'package' : 'anything'}
ref={searchModal}
/>
<chakra.button
flex="1"
type="button"
Expand Down

0 comments on commit ae2ebe9

Please sign in to comment.