Search: fix 'Clear filters' button (#50283)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
(cherry picked from commit 49112c8356)
This commit is contained in:
@@ -60,7 +60,13 @@ function DashboardSearchNew({ onCloseSearch }: Props) {
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.search}>
|
||||
<SearchView showManage={false} queryText={query.query} />
|
||||
<SearchView
|
||||
showManage={false}
|
||||
queryText={query.query}
|
||||
onQueryTextChange={(newQueryText) => {
|
||||
setInputValue(newQueryText);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -57,6 +57,9 @@ export const ManageDashboardsNew = React.memo(({ folder }: Props) => {
|
||||
showManage={isEditor || hasEditPermissionInFolders || canSave}
|
||||
folderDTO={folder}
|
||||
queryText={query.query}
|
||||
onQueryTextChange={(newQueryText) => {
|
||||
setInputValue(newQueryText);
|
||||
}}
|
||||
hidePseudoFolders={true}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -27,13 +27,19 @@ type SearchViewProps = {
|
||||
showManage: boolean;
|
||||
folderDTO?: FolderDTO;
|
||||
hidePseudoFolders?: boolean; // Recent + starred
|
||||
onQueryTextChange: (newQueryText: string) => void;
|
||||
};
|
||||
|
||||
export const SearchView = ({ showManage, folderDTO, queryText, hidePseudoFolders }: SearchViewProps) => {
|
||||
export const SearchView = ({
|
||||
showManage,
|
||||
folderDTO,
|
||||
queryText,
|
||||
hidePseudoFolders,
|
||||
onQueryTextChange,
|
||||
}: SearchViewProps) => {
|
||||
const styles = useStyles2(getStyles);
|
||||
|
||||
const { query, onQueryChange, onTagFilterChange, onTagAdd, onDatasourceChange, onSortChange, onLayoutChange } =
|
||||
useSearchQuery({});
|
||||
const { query, onTagFilterChange, onTagAdd, onDatasourceChange, onSortChange, onLayoutChange } = useSearchQuery({});
|
||||
query.query = queryText; // Use the query value passed in from parent rather than from URL
|
||||
|
||||
const [searchSelection, setSearchSelection] = useState(newSearchSelection());
|
||||
@@ -101,7 +107,7 @@ export const SearchView = ({ showManage, folderDTO, queryText, hidePseudoFolders
|
||||
clearSelection();
|
||||
setListKey(Date.now());
|
||||
// trigger again the search to the backend
|
||||
onQueryChange(query.query);
|
||||
onQueryTextChange(query.query);
|
||||
};
|
||||
|
||||
const renderResults = () => {
|
||||
@@ -120,7 +126,7 @@ export const SearchView = ({ showManage, folderDTO, queryText, hidePseudoFolders
|
||||
variant="secondary"
|
||||
onClick={() => {
|
||||
if (query.query) {
|
||||
onQueryChange('');
|
||||
onQueryTextChange('');
|
||||
}
|
||||
if (query.tag?.length) {
|
||||
onTagFilterChange([]);
|
||||
@@ -202,7 +208,7 @@ export const SearchView = ({ showManage, folderDTO, queryText, hidePseudoFolders
|
||||
onLayoutChange={(v) => {
|
||||
if (v === SearchLayout.Folders) {
|
||||
if (query.query) {
|
||||
onQueryChange(''); // parent will clear the sort
|
||||
onQueryTextChange(''); // parent will clear the sort
|
||||
}
|
||||
}
|
||||
onLayoutChange(v);
|
||||
|
||||
Reference in New Issue
Block a user