hierarchical term selector for flat taxonomies not working properly - problem with utils/terms.js #65704
Closed
2 tasks done
Labels
[Package] Editor
/packages/editor
[Status] In Progress
Tracking issues with work in progress
[Type] Bug
An existing feature does not function as intended
Description
If following the example in gutenberg/packages/editor/src/components/post-taxonomies/README.md to use the hierarchical term selector with a non-hierarchical taxonomy, non-hierarchical taxonomy does not render terms at all.
Problem lies in gutenberg/packages/editor/src/utils/terms.js. termsByParent is somehow not an array, but an object with one 'undefined' key.
So the return statement:
return fillWithChildren( termsByParent[ '0' ] || [] );
in function buildTermsTree() always returns empty array.
If the return statement is replaced with:
return fillWithChildren( Object.values(termsByParent)[0] || [] );
the terms function properly again.
It would be also nice if HierarchicalTermsSelector automatically removed rendering of dropdown for parent term if using non-hierarchical taxonomy. Will post a comment to the issue, if I am able to propose a solution.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
Wordpress version: 6.6.2
Theme: custom theme in development with no other changes to the gutenberg editor so far
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
The text was updated successfully, but these errors were encountered: