Skip to content

Commit 6aebfc5

Browse files
Merge pull request openshift#16151 from rhamilto/OCPBUGS-63391
OCPBUGS-63391: Replace DataViewTextFilter with existing custom TextFilter
2 parents 753df3e + 7049a5d commit 6aebfc5

8 files changed

Lines changed: 60 additions & 40 deletions

File tree

frontend/packages/console-app/src/components/data-view/ConsoleDataView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
DataView,
1111
DataViewState,
1212
DataViewTable,
13-
DataViewTextFilter,
1413
DataViewToolbar,
1514
} from '@patternfly/react-data-view';
1615
import DataViewFilters from '@patternfly/react-data-view/dist/cjs/DataViewFilters';
@@ -26,6 +25,7 @@ import { LazyColumnManagementModalOverlay } from '@console/internal/components/m
2625
import { EmptyBox } from '@console/shared/src/components/empty-state/EmptyBox';
2726
import { StatusBox } from '@console/shared/src/components/status/StatusBox';
2827
import { DataViewLabelFilter } from './DataViewLabelFilter';
28+
import { DataViewTextFilter } from './DataViewTextFilter';
2929
import { useConsoleDataViewData } from './useConsoleDataViewData';
3030
import { useConsoleDataViewFilters } from './useConsoleDataViewFilters';
3131

frontend/packages/console-app/src/components/data-view/DataViewLabelFilter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const DataViewLabelFilter = <TData,>({
4545
applyLabelFilters([]);
4646
}}
4747
>
48-
<div className="pf-v6-c-input-group co-filter-group">
48+
<div className="pf-v6-c-input-group">
4949
<AutocompleteInput
5050
color="purple"
5151
onSuggestionSelect={(selected) => {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import type { FormEvent } from 'react';
2+
import { useEffect, useState } from 'react';
3+
import { ToolbarFilter } from '@patternfly/react-core';
4+
import { useSearchParams } from 'react-router';
5+
import { TextFilter } from '@console/internal/components/factory/text-filter';
6+
7+
type DataViewTextFilterProps = {
8+
title: string;
9+
filterId: string;
10+
placeholder: string;
11+
onChange?: (key: string, selectedValue: string) => void;
12+
showToolbarItem?: boolean;
13+
};
14+
15+
export const DataViewTextFilter = ({
16+
title,
17+
filterId,
18+
placeholder,
19+
onChange,
20+
showToolbarItem,
21+
}: DataViewTextFilterProps) => {
22+
const [searchParams] = useSearchParams();
23+
const [inputText, setInputText] = useState(searchParams.get(filterId) ?? '');
24+
25+
// Sync local state with URL changes
26+
useEffect(() => {
27+
setInputText(searchParams.get(filterId) ?? '');
28+
}, [searchParams, filterId]);
29+
30+
const handleChange = (_event: FormEvent<HTMLInputElement>, value: string) => {
31+
setInputText(value);
32+
onChange?.(filterId, value);
33+
};
34+
35+
const handleDeleteChip = () => {
36+
setInputText('');
37+
onChange?.(filterId, '');
38+
};
39+
40+
return (
41+
<ToolbarFilter
42+
categoryName={title}
43+
showToolbarItem={showToolbarItem}
44+
labels={inputText ? [inputText] : []}
45+
deleteLabel={handleDeleteChip}
46+
>
47+
<TextFilter
48+
label={filterId}
49+
placeholder={placeholder}
50+
value={inputText}
51+
onChange={handleChange}
52+
/>
53+
</ToolbarFilter>
54+
);
55+
};

frontend/packages/helm-plugin/integration-tests/support/pages/helm/helm-page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const helmPage = {
1212
search: (name: string) => {
1313
cy.get(helmPO.filters).within(() => cy.get('.pf-v6-c-menu-toggle').first().click());
1414
cy.get('.pf-v6-c-menu__list-item').contains('Name').click();
15-
cy.get('[aria-label="Name filter"]').clear().type(name);
15+
cy.get('[aria-label="Filter by name"]').clear().type(name);
1616
},
1717
verifyHelmReleasesDisplayed: () => cy.get(helmPO.table).should('be.visible'),
1818
clickHelmReleaseName: (name: string) => cy.get(`a[title="${name}"]`).click(),

frontend/packages/integration-tests-cypress/views/list-page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const listPage = {
6262
cy.get('.pf-v6-c-menu-toggle').first().click(),
6363
);
6464
cy.get('.pf-v6-c-menu__list-item').contains('Name').click();
65-
cy.get('[aria-label="Name filter"]').clear().type(name);
65+
cy.get('[aria-label="Filter by name"]').clear().type(name);
6666
},
6767
by: (checkboxLabel: string) => {
6868
cy.get('[data-ouia-component-id="DataViewCheckboxFilter"]').click();

frontend/public/components/_autocomplete.scss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
position: relative;
33
width: 100%;
44
z-index: var(--pf-t--global--z-index--sm);
5-
@media (max-width: $screen-xs-min) {
6-
max-width: calc(100% - 95px);
7-
}
8-
@media (min-width: $screen-xs-min) and (max-width: $screen-sm-min) {
9-
max-width: 200px;
10-
}
115
}
126

137
.co-suggestion-box__suggestions {
@@ -17,9 +11,6 @@
1711
gap: var(--pf-t--global--spacer--gap--group--vertical);
1812
position: absolute;
1913
width: 100%;
20-
@media (min-width: $screen-xs-min) and (max-width: $screen-sm-min) {
21-
max-width: 200px;
22-
}
2314
}
2415

2516
.co-suggestion-box__suggestions--shadowed {
Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
.co-filter-dropdown__item {
2-
display: inline-flex;
3-
pointer-events: none;
4-
}
5-
6-
.co-filter-dropdown__list-item {
7-
list-style: none;
8-
}
9-
10-
/* No way to reach this ul */
11-
.co-filter-dropdown-group > ul {
12-
margin-left: 0;
13-
padding-left: 0;
14-
}
15-
16-
.co-filter-dropdown-item {
17-
display: inline-flex;
18-
margin: var(--pf-t--global--spacer--xs) 0;
19-
}
20-
211
.co-filter-dropdown-item__name {
222
padding: 0 var(--pf-t--global--spacer--xs);
233
}
24-
25-
@media (min-width: $pf-v6-global--breakpoint--md) {
26-
.co-filter-group {
27-
width: 350px !important; // enable full placeholder text to display
28-
}
29-
}

frontend/public/components/filter-toolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ export const FilterToolbar: FC<FilterToolbarProps> = ({
444444
}}
445445
categoryName={translatedNameFilterTitle}
446446
>
447-
<div className="pf-v6-c-input-group co-filter-group">
447+
<div className="pf-v6-c-input-group">
448448
{showSearchFiltersDropdown && (
449449
<ConsoleSelect
450450
alwaysShowTitle

0 commit comments

Comments
 (0)