You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug - DataViewFilters - childrenHash from JSON.stringify results in cyclic object value #12536
Describe the problem
When using DataViewFilters with a child DataViewCheckboxFilter where the options have a label with a component (e.g. with an icon), the calculation of childrenHash via JSON.stringify results in a JavaScript cyclic object value error.
How do you reproduce the problem?
Provide steps to reproduce. A codesandbox demonstrating the problem is appreciated.
Expected behavior
I expect to be able to use a React component in the option labels. The goal is to render select list with options having icons and possibly tool tips.
Is this issue blocking you?
Worked around this by creating a copy of DataViewFilters in our project with a stricter set of properties provided to JSON.stringify [1].
Screenshots
Desired component:
What is your environment?
OS: Fedora 43
Browser: Firefox
Version: 151
What is your product and what release date are you targeting?
StreamsHub Console [2] (user interface for Kafka clusters), planning to release in a week or so, likely with described work-around.
Thanks for the detailed report and the codesandbox, that made this straightforward to reproduce.
I traced the crash to how DataViewFilters builds its childrenHash. It maps over its children and runs JSON.stringify on each child's full props to produce a string it uses for change detection. That is fine for plain filters, but a DataViewCheckboxFilter whose option label is a React element (an icon, a tooltip, or any component) places React elements inside those props. React elements carry internal circular references through their owner fiber, and JSON.stringify cannot serialize a circular structure, so it throws the "cyclic object value" error you saw and the component fails to render. That also explains why your workaround of passing a stricter set of properties to JSON.stringify avoided it.
The key detail is that childrenHash is used only as the dependency for the filterItems memo, and filterItems reads just filterId and title from each child. So the hash never actually needs to serialize a label's element internals. The fix keeps the existing hashing but adds a JSON.stringify replacer that turns any nested React element into a small, stable descriptor ({ type, key }) instead of walking into its circular internals. Ordinary props are still hashed exactly as before, so change detection behavior is unchanged for existing usage. It simply stops crashing when a label is a component.
I also added a regression test that renders a DataViewCheckboxFilter with a React element as an option label, created inside a wrapper component so the element has an owner (which is what triggers the cycle in real usage). It fails on main with the same error and passes with the fix, and the full DataViewFilters and DataViewCheckboxFilter suites plus snapshots still pass.
Since the component lives in react-data-view rather than this repo, I opened the PR there patternfly/react-data-view#686.
Happy to switch to narrowing the hashed properties instead of a replacer if you prefer that approach.
Activity
aloktomarr commentedon Jul 26, 2026
Thanks for the detailed report and the codesandbox, that made this straightforward to reproduce.
I traced the crash to how DataViewFilters builds its childrenHash. It maps over its children and runs JSON.stringify on each child's full props to produce a string it uses for change detection. That is fine for plain filters, but a DataViewCheckboxFilter whose option label is a React element (an icon, a tooltip, or any component) places React elements inside those props. React elements carry internal circular references through their owner fiber, and JSON.stringify cannot serialize a circular structure, so it throws the "cyclic object value" error you saw and the component fails to render. That also explains why your workaround of passing a stricter set of properties to JSON.stringify avoided it.
The key detail is that childrenHash is used only as the dependency for the filterItems memo, and filterItems reads just filterId and title from each child. So the hash never actually needs to serialize a label's element internals. The fix keeps the existing hashing but adds a JSON.stringify replacer that turns any nested React element into a small, stable descriptor ({ type, key }) instead of walking into its circular internals. Ordinary props are still hashed exactly as before, so change detection behavior is unchanged for existing usage. It simply stops crashing when a label is a component.
I also added a regression test that renders a DataViewCheckboxFilter with a React element as an option label, created inside a wrapper component so the element has an owner (which is what triggers the cycle in real usage). It fails on main with the same error and passes with the fix, and the full DataViewFilters and DataViewCheckboxFilter suites plus snapshots still pass.
Since the component lives in react-data-view rather than this repo, I opened the PR there patternfly/react-data-view#686.
Happy to switch to narrowing the hashed properties instead of a replacer if you prefer that approach.
github-actions commentedon Sep 27, 2026
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.