-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
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
- add code to theme as per instructions in gutenberg/packages/editor/src/components/post-taxonomies/README.md
- open any post in gutenberg editor
- observe that taxonomies with flat terms do not render any terms
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.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes