It doesn't seem like HierarchicalTermSelector and FlatTermSelector can be accessed from a plugin, so they can't be reused.
I'd like be to able to do something like:
import HierarchicalTermSelector from '@wordpress/editor';
function customizeTaxonomySelector( OriginalComponent ) {
return function( props ) {
if ( 'my_taxonomy' !== props.slug ) {
return <OriginalComponent { ...props } />;
}
return <HierarchicalTermSelector { ...props } />;
};
}
wp.hooks.addFilter( 'editor.PostTaxonomyType', 'my-custom-plugin', customizeTaxonomySelector );
My use case is https://github.com/WordPress/gutenberg/issues/13816#issuecomment-532885577, where I want to use the hierarchical term selector w/ a flat taxonomy, because it's a better UX for that specific taxonomy.
Possibly related #2761
That鈥檚 a valid use case to expose them. I didn鈥檛 anticipate it happening to be honest 馃槂
Any updates on this? Almost every website we make requires a flat taxonomy to be shown as checkboxes, or that only allows a single selection (radio or dropdown). Extending HierarchicalTermSelector seems to be possible way to do this, aside from these options just being in core.
Setting show_in_rest to true makes the taxonomy selection appear in Gutenberg editor.
However, the taxonomy selection field stays grey/disabled and a JavaScript error occurs:
Warning: Can't perform a React state update on an unmounted component.
Related: https://github.com/WordPress/gutenberg/issues/13517#issuecomment-708486733
Most helpful comment
Any updates on this? Almost every website we make requires a flat taxonomy to be shown as checkboxes, or that only allows a single selection (radio or dropdown). Extending
HierarchicalTermSelectorseems to be possible way to do this, aside from these options just being in core.