Icon in search bar to show/hide search results

Summary:
1. Added icon to search bar to manually trigger the hide/show search context/results functionality, which was only triggerable by ctrl(now migrated to ctrl+t) before.
2. Added tool tips to increase visibility of keyboard shortcuts

Changelog: Added icon for showing search result context(only triggered by keyboard shortcut before). Added tool tips to search bar icons.

Reviewed By: mweststrate

Differential Revision: D38207087

fbshipit-source-id: a34c1322294ed8091ea3f90d2f1f206af981c9ca
This commit is contained in:
Feiyu Wong
2022-07-27 12:19:51 -07:00
committed by Facebook GitHub Bot
parent 499275af8a
commit a47528a726

View File

@@ -7,8 +7,8 @@
* @format * @format
*/ */
import {HistoryOutlined, MenuOutlined} from '@ant-design/icons'; import {HistoryOutlined, MenuOutlined, SwapOutlined} from '@ant-design/icons';
import {Button, Dropdown, Input, AutoComplete, InputRef} from 'antd'; import {Button, Dropdown, Input, AutoComplete, InputRef, Tooltip} from 'antd';
import React, {memo, useCallback, useMemo} from 'react'; import React, {memo, useCallback, useMemo} from 'react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
@@ -86,6 +86,9 @@ export const TableSearch = memo(function TableSearch({
}, },
[dispatch], [dispatch],
); );
const toggleHideResults = useCallback(() => {
dispatch({type: 'toggleSearchValue'});
}, [dispatch]);
const onKeyDown = useCallback( const onKeyDown = useCallback(
(e: React.KeyboardEvent<any>) => { (e: React.KeyboardEvent<any>) => {
switch (e.key) { switch (e.key) {
@@ -174,12 +177,16 @@ export const TableSearch = memo(function TableSearch({
suffix={ suffix={
<> <>
{options.length ? ( {options.length ? (
<RegexButton <Tooltip
onClick={() => { placement="topLeft"
toggleSearchDropdown(!showHistory); title="Show search history (ctrl+f)">
}}> <RegexButton
<HistoryOutlined /> onClick={() => {
</RegexButton> toggleSearchDropdown(!showHistory);
}}>
<HistoryOutlined />
</RegexButton>
</Tooltip>
) : null} ) : null}
<RegexButton <RegexButton
size="small" size="small"
@@ -200,6 +207,16 @@ export const TableSearch = memo(function TableSearch({
title={regexError || 'Search using Regex'}> title={regexError || 'Search using Regex'}>
.* .*
</RegexButton> </RegexButton>
<Tooltip
placement="topRight"
title="Show/Hide search results (ctrl+t)">
<RegexButton
onClick={() => {
toggleHideResults();
}}>
<SwapOutlined />
</RegexButton>
</Tooltip>
</> </>
} }
onChange={(e) => { onChange={(e) => {