Skip to content

[Element Editor] Fix relation grid search not matching visible column values - #3911

Open
mw-keoz wants to merge 2 commits into
pimcore:2026.2from
mw-keoz:fix/relation-grid-search-visible-columns-2026x
Open

[Element Editor] Fix relation grid search not matching visible column values#3911
mw-keoz wants to merge 2 commits into
pimcore:2026.2from
mw-keoz:fix/relation-grid-search-visible-columns-2026x

Conversation

@mw-keoz

@mw-keoz mw-keoz commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What

Fix search in the many-to-many object relation editor so it matches the visible column values, not only the object path.

Why

When a many-to-many object relation is configured with visibleFields, the search box above the grid should match those visible column values. applySearchFilter (core/components/many-to-many-relation/hooks/use-value.ts) joins each grid row to its visible-field values by id: it builds a Map keyed by field.id, dropping any entry with a nil id (.filter(field => !isNil(field?.id))), then looks up visibleFieldsMap.get(item.id).

But the producer (visibleFieldsValue in many-to-many-object-relation.tsx) emits only the column key/value pairs, with no id. Every entry is therefore dropped from the map, the visible-field branch never matches, and search silently falls back to matching fullPath only — so typing a value that is plainly visible in a column returns nothing.

Fix

Attach the row id to each produced record so the join resolves.

   const visibleFieldsValue = useMemo(() => {
     return mergedGridFullData.map(item => {
-      return item?.columns?.reduce<Record<string, any>>((acc, col) => {
+      const columns = item?.columns?.reduce<Record<string, any>>((acc, col) => {
         acc[col.key!] = col.value
         return acc
       }, {})
+
+      return columns === undefined ? undefined : { ...columns, id: item.id }
     })
   }, [mergedGridFullData])

The fullPath/id/type fallback branch is untouched.

Testing

  • Manual: open an object with a many-to-many object relation that has visibleFields configured; assign a few objects; type a value that appears in a visible column (not in the path). Before: no match. After: the row matches. Path/id/type search unchanged.

Copilot AI review requested due to automatic review settings July 21, 2026 06:32
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Verdict: Needs changes. The fix correctly restores visible-column search by attaching each row ID at the producer boundary (many-to-many-object-relation.tsx:227).

Changes:

  • Adds row IDs to visible-field records, addressing the root cause.
  • Preserves fallback search and existing APIs.
  • No automated regression test was added; the narrow search behavior should be covered before approval.
  • One non-blocking type-check convention nit remains at line 227.

@mw-keoz

mw-keoz commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@mw-keoz

mw-keoz commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review — both points addressed in 51c164cab:

  • Regression coverage: added use-value.test.ts, a renderHook(useValue) suite for the visible-column search behavior. A term present only in a column value matches only when the visibleFieldsValue entries carry the row id, and the filter falls back to fullPath when they don't — the exact contract this fix restores. A third case confirms the fullPath fallback still works.
  • Type-safe guard: switched the producer's columns === undefined to lodash isUndefined, consistent with the rest of the file.

Locally green: jest (3/3), tsc --noEmit clean, eslint clean on both files.

FYI the red build / install check isn't related to this change — the pull_request_target workflow's actions/checkout refuses to check out fork-PR code ("pwn request" guard), so it fails the same way for any external fork PR.

@ValeriaMaltseva
ValeriaMaltseva self-requested a review July 21, 2026 07:57
mw-keoz added 2 commits July 21, 2026 10:29
… values

In the many-to-many object relation editor the search box should match the
configured visibleFields column values, not only the object path. applySearchFilter
joins each row to its visible-field values by id (a Map keyed by field.id, dropping
nil-id entries), but the visibleFieldsValue producer emitted only column key/value
pairs with no id, so every entry was dropped and search silently fell back to
matching fullPath only. Attach the row id to each produced record so the join
resolves.
…defined guard

- Add a renderHook(useValue) regression test for visible-column search: a column
  value matches only when visibleFieldsValue entries carry the row id, and the
  filter falls back to fullPath when they do not.
- Use lodash isUndefined for the producer's undefined check, matching the file's
  existing guard style (review feedback).
@mw-keoz
mw-keoz force-pushed the fix/relation-grid-search-visible-columns-2026x branch from 51c164c to 2011b53 Compare July 21, 2026 08:29
@mw-keoz
mw-keoz changed the base branch from 2026.x to 2026.2 July 21, 2026 08:29
@sonarqubecloud

Copy link
Copy Markdown

@ValeriaMaltseva

Copy link
Copy Markdown
Contributor

@mw-keoz
Hi! Thanks for taking the time to contribute :)

At the moment, I can't reproduce this issue, either on 2025.4.9 or 2026.2.2. Could you please double-check whether the problem still persists? If it does, would you mind providing some additional details or steps to reproduce it? That would help us investigate further. Thanks!

@ValeriaMaltseva ValeriaMaltseva left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mw-keoz
Hi! Just wanted to kindly remind you about this. Thanks! :)

#3911 (comment)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants