Skip to content

OCPBUGS-63391: Replace DataViewTextFilter with existing custom TextFilter#16151

Open
rhamilto wants to merge 1 commit intoopenshift:mainfrom
rhamilto:OCPBUGS-63391
Open

OCPBUGS-63391: Replace DataViewTextFilter with existing custom TextFilter#16151
rhamilto wants to merge 1 commit intoopenshift:mainfrom
rhamilto:OCPBUGS-63391

Conversation

@rhamilto
Copy link
Member

@rhamilto rhamilto commented Mar 16, 2026

Description

This PR replaces PatternFly's DataViewTextFilter with the legacy TextFilter component into the DataView filter system in order to re-enable the keyboard shortcut to the name text input.

After

Screen.Recording.2026-03-16.at.12.15.46.PM.mov

Changes

  • Created DataViewTextFilter.tsx wrapper component that wraps TextFilter in ToolbarFilter
  • Removed PatternFly's DataViewTextFilter import from ConsoleDataView.tsx
  • Integrated the custom wrapper at the same location in the code
  • Fixes test helpers to use correct aria-label for name filter

Benefits

  • Maintains keyboard shortcut functionality (built into TextFilter)
  • Properly displays "Name" in the filter dropdown
  • Avoids circular structure errors
  • Compatible with existing DataView filter system

Testing

  • Verified TypeScript compilation passes
  • Verified ESLint passes
  • Tested filter functionality with keyboard shortcuts

Summary by CodeRabbit

  • New Features
    • Added a text filtering component for data views that integrates with the toolbar and supports URL parameter-based filter state persistence.

@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 16, 2026
@openshift-ci-robot
Copy link
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-63391, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Description

This PR replaces PatternFly's DataViewTextFilter with a custom wrapper that integrates the legacy TextFilter component into the DataView filter system.

Changes

  • Created DataViewTextFilter.tsx wrapper component that wraps TextFilter in ToolbarFilter
  • Removed PatternFly's DataViewTextFilter import from ConsoleDataView.tsx
  • Integrated the custom wrapper at the same location in the code

Benefits

  • Maintains keyboard shortcut functionality (built into TextFilter)
  • Properly displays "Name" in the filter dropdown
  • Avoids circular structure errors
  • Compatible with existing DataView filter system

Testing

  • Verified TypeScript compilation passes
  • Verified ESLint passes
  • Tested filter functionality with keyboard shortcuts

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from TheRealJon and sg00dwin March 16, 2026 15:04
@openshift-ci openshift-ci bot added component/core Related to console core functionality approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 16, 2026
@rhamilto
Copy link
Member Author

/jira refresh
/cherry-pick release-4.21

@openshift-cherrypick-robot

@rhamilto: once the present PR merges, I will cherry-pick it on top of release-4.21 in a new PR and assign it to you.

Details

In response to this:

/jira refresh
/cherry-pick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 16, 2026
@openshift-ci-robot
Copy link
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-63391, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

Details

In response to this:

/jira refresh
/cherry-pick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-63391, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

Details

In response to this:

Description

This PR replaces PatternFly's DataViewTextFilter with a custom wrapper that integrates the legacy TextFilter component into the DataView filter system.

After

Untitled.mov

Changes

  • Created DataViewTextFilter.tsx wrapper component that wraps TextFilter in ToolbarFilter
  • Removed PatternFly's DataViewTextFilter import from ConsoleDataView.tsx
  • Integrated the custom wrapper at the same location in the code

Benefits

  • Maintains keyboard shortcut functionality (built into TextFilter)
  • Properly displays "Name" in the filter dropdown
  • Avoids circular structure errors
  • Compatible with existing DataView filter system

Testing

  • Verified TypeScript compilation passes
  • Verified ESLint passes
  • Tested filter functionality with keyboard shortcuts

Summary by CodeRabbit

  • New Features
  • Added a text filtering component for data views that integrates with the toolbar and supports URL parameter-based filter state persistence.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@rhamilto
Copy link
Member Author

/assign @vojtechszocs

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

📝 Walkthrough

Walkthrough

This change extracts the DataViewTextFilter component into a dedicated local module. A new file introduces the DataViewTextFilter component, which wraps PatternFly's ToolbarFilter and TextFilter components. The component accepts configuration props (title, filterId, placeholder, onChange, showToolbarItem) and manages filter state by reading from URL search parameters while maintaining local input state. The ConsoleDataView component's import is updated to reference the new local module instead of the PatternFly library source.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can get early access to new features in CodeRabbit.

Enable the early_access setting to enable early access features such as new models, tools, and more.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@frontend/packages/console-app/src/components/data-view/DataViewTextFilter.tsx`:
- Around line 21-23: The input clearing bug is caused by rendering the field as
inputText || filterValue and not initializing/syncing local state from the URL;
update the component to initialize inputText from searchParams (useSearchParams)
on mount and stop using the fallback (remove uses of `inputText ||
filterValue`), and add a useEffect that sets
setInputText(searchParams.get(filterId) ?? '') when searchParams or filterId
change so the local state is the single source of truth while still reacting to
external URL navigation; adjust any usage in the component that reads
`filterValue` (e.g., in the input value and change handlers) to rely on
inputText and setInputText.
- Line 1: Add the React namespace import and update the event handler type where
React.FormEvent is used in DataViewTextFilter.tsx: import the React symbol (e.g.
import React from 'react' or import * as React from 'react') at the top of the
file, then update the handler signature that currently references
React.FormEvent (the function around line 25) to use the proper generic for an
input element (e.g. React.FormEvent<HTMLInputElement> or
React.ChangeEvent<HTMLInputElement>) so the type resolves correctly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 9a7b173a-7747-40c2-84cc-38495b4d69cd

📥 Commits

Reviewing files that changed from the base of the PR and between 4d1f6f7 and e17e0c4.

📒 Files selected for processing (2)
  • frontend/packages/console-app/src/components/data-view/ConsoleDataView.tsx
  • frontend/packages/console-app/src/components/data-view/DataViewTextFilter.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/packages/console-app/src/components/data-view/DataViewTextFilter.tsx
  • frontend/packages/console-app/src/components/data-view/ConsoleDataView.tsx
🧬 Code graph analysis (1)
frontend/packages/console-app/src/components/data-view/DataViewTextFilter.tsx (1)
frontend/public/components/utils/tile-view-page.jsx (1)
  • searchParams (466-466)
🔇 Additional comments (1)
frontend/packages/console-app/src/components/data-view/ConsoleDataView.tsx (1)

28-28: Import switch to local wrapper looks correct.

The change from PatternFly's DataViewTextFilter to the local implementation maintains the same component interface and integrates cleanly with the existing DataViewFilters context. This preserves the established filtering architecture while enabling the custom behavior.

@@ -0,0 +1,40 @@
import { useState } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing React namespace import for type annotation.

React.FormEvent is used on line 25, but only useState is imported from 'react'. Depending on your TypeScript configuration, this may cause a compilation error.

🔧 Proposed fix
-import { useState } from 'react';
+import type { FormEvent } from 'react';
+import { useState } from 'react';
 import { ToolbarFilter } from '@patternfly/react-core';
 import { useSearchParams } from 'react-router';
 import { TextFilter } from '@console/internal/components/factory/text-filter';

Then update the handler signature:

-  const handleChange = (_event: React.FormEvent<HTMLInputElement>, value: string) => {
+  const handleChange = (_event: FormEvent<HTMLInputElement>, value: string) => {

Also applies to: 25-25

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/console-app/src/components/data-view/DataViewTextFilter.tsx`
at line 1, Add the React namespace import and update the event handler type
where React.FormEvent is used in DataViewTextFilter.tsx: import the React symbol
(e.g. import React from 'react' or import * as React from 'react') at the top of
the file, then update the handler signature that currently references
React.FormEvent (the function around line 25) to use the proper generic for an
input element (e.g. React.FormEvent<HTMLInputElement> or
React.ChangeEvent<HTMLInputElement>) so the type resolves correctly.

Comment on lines +21 to +23
const [searchParams] = useSearchParams();
const [inputText, setInputText] = useState('');
const filterValue = searchParams.get(filterId) ?? '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

State synchronization bug prevents clearing the filter when URL params exist.

The pattern inputText || filterValue has a subtle but impactful issue: when a user clears the input, inputText becomes '' (falsy), causing the component to fall back to displaying filterValue from the URL. This makes it impossible to clear the filter field when URL params are present.

Consider initializing inputText from the URL param on mount, then treating local state as the source of truth:

🐛 Proposed fix
 export const DataViewTextFilter = ({
   title,
   filterId,
   placeholder,
   onChange,
   showToolbarItem,
 }: DataViewTextFilterProps) => {
   const [searchParams] = useSearchParams();
-  const [inputText, setInputText] = useState('');
-  const filterValue = searchParams.get(filterId) ?? '';
+  const [inputText, setInputText] = useState(() => searchParams.get(filterId) ?? '');

   const handleChange = (_event: React.FormEvent<HTMLInputElement>, value: string) => {
     setInputText(value);
     onChange?.(filterId, value);
   };

   return (
     <ToolbarFilter categoryName={title} showToolbarItem={showToolbarItem}>
       <TextFilter
         label={filterId}
         placeholder={placeholder}
-        value={inputText || filterValue}
+        value={inputText}
         onChange={handleChange}
       />
     </ToolbarFilter>
   );
 };

If the component should also react to external URL changes (browser back/forward navigation), you'd need an effect to sync:

useEffect(() => {
  setInputText(searchParams.get(filterId) ?? '');
}, [searchParams, filterId]);

Also applies to: 35-35

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@frontend/packages/console-app/src/components/data-view/DataViewTextFilter.tsx`
around lines 21 - 23, The input clearing bug is caused by rendering the field as
inputText || filterValue and not initializing/syncing local state from the URL;
update the component to initialize inputText from searchParams (useSearchParams)
on mount and stop using the fallback (remove uses of `inputText ||
filterValue`), and add a useEffect that sets
setInputText(searchParams.get(filterId) ?? '') when searchParams or filterId
change so the local state is the single source of truth while still reacting to
external URL navigation; adjust any usage in the component that reads
`filterValue` (e.g., in the input value and change handlers) to rely on
inputText and setInputText.

@rhamilto
Copy link
Member Author

/hold

This broke the filter chip

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 16, 2026
@rhamilto
Copy link
Member Author

/hold cancel
/retest

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 16, 2026
@rhamilto
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@openshift-ci openshift-ci bot added the kind/cypress Related to Cypress e2e integration testing label Mar 16, 2026
@openshift-ci openshift-ci bot added the component/helm Related to helm-plugin label Mar 16, 2026
@rhamilto rhamilto changed the title OCPBUGS-63391: Replace DataViewTextFilter with custom TextFilter wrapper OCPBUGS-63391: Replace DataViewTextFilter with custom TextFilter Mar 16, 2026
@rhamilto rhamilto changed the title OCPBUGS-63391: Replace DataViewTextFilter with custom TextFilter OCPBUGS-63391: Replace DataViewTextFilter with existing custom TextFilter Mar 16, 2026
@openshift-ci-robot
Copy link
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-63391, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Description

This PR replaces PatternFly's DataViewTextFilter with the legacy TextFilter component into the DataView filter system in order to re-enable the keyboard shortcut to the name text input.

After

Screen.Recording.2026-03-16.at.12.15.46.PM.mov

Changes

  • Created DataViewTextFilter.tsx wrapper component that wraps TextFilter in ToolbarFilter
  • Removed PatternFly's DataViewTextFilter import from ConsoleDataView.tsx
  • Integrated the custom wrapper at the same location in the code
  • Fixes test helpers to use correct aria-label for name filter

Benefits

  • Maintains keyboard shortcut functionality (built into TextFilter)
  • Properly displays "Name" in the filter dropdown
  • Avoids circular structure errors
  • Compatible with existing DataView filter system

Testing

  • Verified TypeScript compilation passes
  • Verified ESLint passes
  • Tested filter functionality with keyboard shortcuts

Summary by CodeRabbit

  • New Features
  • Added a text filtering component for data views that integrates with the toolbar and supports URL parameter-based filter state persistence.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rules are no longer needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rules are orphaned (first block) or no longer needed (second block).

@rhamilto
Copy link
Member Author

/assign @sg00dwin
/assign @yapei

@XiyunZhao
Copy link
Contributor

/verified by @XiyuZhao
Now pressing / now correctly focuses the Filter by name / Filter by label input

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Mar 18, 2026
@openshift-ci-robot
Copy link
Contributor

@XiyunZhao: This PR has been marked as verified by @xiyuzhao.

Details

In response to this:

/verified by @XiyuZhao
Now pressing / now correctly focuses the Filter by name / Filter by label input

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 18, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 18, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhamilto, TheRealJon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@XiyuZhao
Copy link

/verified by @XiyuZhao Now pressing / now correctly focuses the Filter by name / Filter by label input

I think you tagged me by accident. Unsubscribing from this thread now.

@rhamilto
Copy link
Member Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 19, 2026

@rhamilto: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-console 7049a5d link true /test e2e-gcp-console

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/helm Related to helm-plugin jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. kind/cypress Related to Cypress e2e integration testing lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants