[Bug] Class editor: allowed-classes select shows duplicate options and drops classes (folder nodes leak into options) - #3930
Open
alexbaat wants to merge 1 commit into
Conversation
The allowed-classes select in the class editor's relation field settings built its options from the grouped class definition tree, including the folder (group) nodes themselves. Group names derived from class name prefixes often collide with real class names, producing duplicate option values and phantom options, which breaks rendering of the dropdown so that some classes become unselectable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
All contributors have signed the CLA ✍️ ✅ |
pimcore-deployments
marked this pull request as draft
July 23, 2026 10:04
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes invalid and duplicate class options in relation field settings by excluding grouping folders.
Changes:
- Flattens only actual class-definition nodes.
- Adds regression tests for duplicates, folder inclusion, and unloaded data.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
use-class-definition-options.ts |
Excludes folder nodes from selectable options. |
use-class-definition-options.spec.ts |
Adds regression coverage for option generation. |
|
alexbaat
marked this pull request as ready for review
July 23, 2026 10:06
pimcore-deployments
marked this pull request as draft
July 23, 2026 10:06
alexbaat
marked this pull request as ready for review
July 23, 2026 10:20
pimcore-deployments
marked this pull request as draft
July 23, 2026 10:20
Author
|
recheck |
Author
|
I have read the CLA Document and I hereby sign the CLA |
alexbaat
marked this pull request as ready for review
July 23, 2026 10:30
ValeriaMaltseva
self-requested a review
July 23, 2026 11:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Changes in this pull request
Resolves pimcore/platform-version#239
useClassDefinitionOptionsbuilds the options for the allowed classes select shown in the class editor settings of all relation field types (manyToOneRelation,manyToManyRelation,manyToManyObjectRelation, bothadvanced*variants andreverseObjectRelation). It fetches the class definition tree withwithGroup: trueand flattens it — butflattenTreeNodes()emitted the folder (group) nodes themselves as selectable options in addition to their children.Since
ClassDefinitionTreeService(studio-backend-bundle) derives group names from class name prefixes for classes without an explicit group, a folder is frequently named exactly like a real class. Example: classesMaterialandMaterialGroupare grouped into a folder namedMaterial, so the options containMaterialtwice (folder + class) plus phantom entries for groups that are not classes at all (Royalty, …).Observed behaviour
Materialtwice,Producttwice).Series) no longer show up and cannot be selected.Reproduction
Material,MaterialGroupandSeries(no explicit group set).manyToOneRelationfield to any class and open its settings in the class editor.Materialappears twice,Seriesis missing.Fix
Skip folder nodes in
flattenTreeNodes()and only recurse into their children — folders are grouping containers, not selectable class definitions. This mirrors what the neighbouringuseClassRelationFieldsOptionshook already does. The specialfolderoption added via theincludeFolderparameter is unaffected.Added a Jest spec covering: folder nodes excluded, no duplicate values when a folder shares its name with a class,
includeFolderbehaviour, and the not-yet-loaded state.Additional info
The root cause has two halves: the prefix-based auto-grouping in
ClassDefinitionTreeService::extractGroupNameFromClassName()(studio-backend-bundle) is what makes folder names collide with class names in the first place. This PR fixes the consumer side, which resolves the user-facing bug for all relation field types; rethinking the prefix grouping itself is left out of scope.Reproduced on v2026.1.6 and the bug is still present on
2026.x/v2026.2.1.