Skip to content

Commit

Permalink
fix: exchange search mode should reset filter text
Browse files Browse the repository at this point in the history
  • Loading branch information
caoxing9 committed Nov 21, 2024
1 parent 298e4b4 commit 03a6759
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const SearchButton = (props: ISearchButtonProps) => {
const tableId = useTableId();
const view = useView();
const { fieldId, value, setFieldId, setValue, hideNotMatchRow, setHideNotMatchRow } = useSearch();
console.log('fieldId', fieldId);
const [inputValue, setInputValue] = useState(value);
const [isFocused, setIsFocused] = useState(false);
const { t } = useTranslation(['common', 'table']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Toggle,
} from '@teable/ui-lib';
import { useTranslation } from 'next-i18next';
import { useCallback, useMemo } from 'react';
import { useCallback, useMemo, useState } from 'react';

interface ISearchCommand {
value: string;
Expand Down Expand Up @@ -56,6 +56,8 @@ export const SearchCommand = (props: ISearchCommand) => {

const enableGlobalSearch = value === 'all_fields';

const [filterText, setFilterText] = useState('');

return (
<Command filter={commandFilter}>
{
Expand All @@ -64,6 +66,10 @@ export const SearchCommand = (props: ISearchCommand) => {
placeholder={t('actions.search')}
className="h-8 text-xs"
disabled={enableGlobalSearch}
value={filterText}
onValueChange={(value) => {
setFilterText(value);
}}
/>
<CommandList className="my-2 max-h-64">
{<CommandEmpty>{t('listEmptyTips')}</CommandEmpty>}
Expand Down Expand Up @@ -124,6 +130,7 @@ export const SearchCommand = (props: ISearchCommand) => {
pressed={enableGlobalSearch}
onPressedChange={() => {
onChange(['all_fields']);
setFilterText('');
}}
size={'sm'}
className="flex flex-1 items-center truncate p-0"
Expand Down

0 comments on commit 03a6759

Please sign in to comment.