PhoenixKit.Modules.Publishing.Web.Components.CategoriesPicker (PhoenixKitPublishing v0.4.6)

Copy Markdown View Source

The post editor's category field: a typeahead plus a row of chips.

Categories are version-level — see PublishingVersion.get_category_uuids/1. A post's subject can change between versions, and an old version keeps the filing it was published under. So this component doesn't persist anything itself: it edits form["category_uuids"] through the parent LiveView and rides the ordinary save, exactly like featured or the SEO fields. That also means a brand-new post can be filed before its first save, which the old post-level version couldn't do — it had nothing to attach a row to and showed a "save the post first" notice instead.

The typeahead replaced a checkbox tree. A tree is the wrong shape here: it grows without bound, it forces the writer to scan for the one entry they already have in mind, and indentation is a poor way to show which of forty boxes are ticked. Typing narrows; the chips show the answer.

Hierarchy still matters for picking — two categories can share a name under different parents — so each suggestion carries its parent chain as a sublabel rather than as indentation.

Required assigns: :id, :group_slug, :selected (list of uuids), :language, :disabled. Changes are announced to the parent LiveView as {:categories_changed, uuids} — the parent owns the form, so it has to be the one to write to it, mark the post dirty and let the collaborative broadcast go out.