block-components icon indicating copy to clipboard operation
block-components copied to clipboard

Add: `TermPicker` Component

Open fabiankaegy opened this issue 3 years ago • 4 comments

A common pattern that I'm coming across again and again is that we need to override the core UI for a term picker. By default core allows you to choose multiple categories / tags and that is the same for custom post types. However there are many cases where we need to be able to add a term which should be displayed in a radio control so you can only select one item.

This currently is rather cumbersome and not very straightforward. I'd love for us to come up with a nicer developer experience that leads to a better UX across all projects.

fabiankaegy avatar Jan 18 '22 09:01 fabiankaegy

I was browsing for some solutions and found this -https://github.com/WordPress/gutenberg/blob/trunk/packages/editor/src/components/post-taxonomies/hierarchical-term-selector.js which we can technically copy-paste, add a filter on top, and replace the checkboxes to the radio.

I saw this existing project that does that but with an old codebase: https://github.com/5ally/my-term-selector

Is this close to the idea here?

xavortm avatar Mar 03 '22 16:03 xavortm

@xavortm yes that is exactly what I was thinking. We want the same functionality as the core hierarchical-term-selector just as radio controls

fabiankaegy avatar Mar 04 '22 07:03 fabiankaegy

Awesome ^^ I will look into this ticket then 👍 Assigning to myself for now and if there is no update I will comment again here

xavortm avatar Mar 04 '22 10:03 xavortm

Maybe that took more than expected but I got to it in the end :D I have opened a draft PR where I am working on a proof of concept that we can tweak later (mainly on how to render visually child categories).

xavortm avatar Jul 04 '22 15:07 xavortm