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

refactor: hide shortcut tips for search if not empty #1939

Merged
merged 4 commits into from
Dec 26, 2023
Merged
Changes from 1 commit
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
13 changes: 8 additions & 5 deletions src/client/theme-default/slots/SearchBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { ReactComponent as IconArrowDown } from '@ant-design/icons-svg/inline-sv
import { ReactComponent as IconArrowUp } from '@ant-design/icons-svg/inline-svg/outlined/arrow-up.svg';
import { ReactComponent as IconSearch } from '@ant-design/icons-svg/inline-svg/outlined/search.svg';
import { useSiteSearch } from 'dumi';
import React, { useEffect, useRef, useState, type FC } from 'react';
import SearchResult from 'dumi/theme/slots/SearchResult';
import './index.less';
import React, { useEffect, useRef, useState, type FC } from 'react';
import { Input } from './Input';
import { Mask } from './Mask';
export { Input as SearchInput } from './Input';
export { Mask as SearchMask } from './Mask';
import './index.less';

const isAppleDevice = /(mac|iphone|ipod|ipad)/i.test(
typeof navigator !== 'undefined' ? navigator?.platform : '',
Expand Down Expand Up @@ -87,7 +85,9 @@ const SearchBar: FC = () => {
onChange={(keywords) => setKeywords(keywords)}
ref={inputRef}
/>
<span className="dumi-default-search-shortcut">{symbol} K</span>
{!keywords && (
crazyair marked this conversation as resolved.
Show resolved Hide resolved
<span className="dumi-default-search-shortcut">{symbol} K</span>
)}
{keywords.trim() &&
focusing &&
(result.length || !loading) &&
Expand Down Expand Up @@ -163,4 +163,7 @@ const SearchBar: FC = () => {
);
};

export { Input as SearchInput } from './Input';
export { Mask as SearchMask } from './Mask';

export default SearchBar;
Loading