discourse/app/assets/stylesheets/common/select-kit
Régis Hanol 8e59848113
FIX: Allow selecting synonyms in composer tag chooser (#39974)
A recent change (#39072) made the composer tag autocomplete pass
`excludeSynonyms: true` so synonyms appeared as disabled rows with a
"Use canonical X instead" message. That blocked a legitimate workflow: a
forum where company names are the canonical tags and stock tickers are
the synonyms, so members can type the shorter ticker. The backend has
always remapped synonym names to their canonical target at save time, so
blocking the selection in the UI was overzealous.

This change keeps the disabled-row UX in admin surfaces where synonyms
genuinely can't be the target (tag groups form, embedding hosts,
webhooks, edit-category-tags, upsert-category/tags) — those still
explicitly pass `excludeSynonyms: true`. In the composer (mini-tag-
chooser) synonyms are now selectable, and the row shows an inline "→
canonical-tag" hint so the user understands what their typed tag will
become.

Fixing the autocomplete surfaced two latent bugs that the previous block
had been masking:

1. After saving, the topic header kept showing the typed synonym names
until a full page reload, because the response of
`TopicsController#update` and `#update_tags` only returned the
`BasicTopicSerializer` fields (no tags), and the client used its
in-memory pre-save tag list to update `topic.tags`. Both endpoints now
include the canonical `tags` array in the response whenever tags were
part of the request, and `Topic.update` / `Topic.updateTags` on the
client overwrite `topic.tags` with that list.

2. Submitting only synonyms of existing tags created an empty
`PostRevision` row. The controller's no-op detector compared raw tag
IDs, so synonym IDs always looked like a change. `PostRevisor` would
start a revision, `apply_tag_changes` would bail out after the canonical
remap matched the existing set, but the bumped version and empty
revision row had already been written. This is fixed at the PostRevisor
level via a new `tag_change_noop?` class method that resolves incoming
tag IDs/names through `COALESCE(target_tag_id, id)` and compares the
canonical set with `topic.tags`. When it matches, `revise!` deletes
`:tags` from `@fields` during normalization, so `should_revise?`
correctly short-circuits before any version bump. The same helper
replaces the controller-level no-op check and also subsumes the existing
"empty tags on empty topic" branch.

Specs cover: synonym row appears selectable with the hint, server
returns canonical tags after a synonym submission, no revision is
created when only synonyms of existing tags are submitted (object and
string forms), and the existing disabled-row UX still applies for
`one_per_topic` and parent-tag groups.
2026-05-22 18:47:59 +02:00
..
_index.scss UX: create combined category and tag settings dropdown (#39099) 2026-04-06 10:09:33 -04:00
categories-admin-dropdown.scss
category-chooser.scss
category-drop.scss DEV: move mobile select-kit CSS to common files (#39055) 2026-04-02 13:46:06 -04:00
category-row.scss UX: ensure read-only only appears once, on the relevant category (#37492) 2026-02-03 15:03:04 -05:00
category-selector.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
color-palette-picker.scss FEATURE: Add previews to color palette selectors (#34129) 2025-08-11 11:51:01 +08:00
color-palettes.scss
combo-box.scss UX: make select-kit disabled state consistent with formkit (#37513) 2026-02-04 08:51:33 +01:00
composer-actions.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
dropdown-select-box.scss DEV: move mobile select-kit CSS to common files (#39055) 2026-04-02 13:46:06 -04:00
email-group-user-chooser.scss DEV: Update lint-configs and auto-fix issues (#31485) 2025-02-24 23:32:31 +01:00
flair-row.scss
future-date-input-selector.scss DEV: Introduce stylelint (#29852) 2025-01-20 15:27:42 +00:00
icon-picker.scss
list-setting.scss
mini-tag-chooser.scss
multi-select.scss UX: make select-kit disabled state consistent with formkit (#37513) 2026-02-04 08:51:33 +01:00
notifications-button.scss
notifications-filter.scss
period-chooser.scss UX: overrule borderadius on period-chooser (#38780) 2026-03-23 11:06:19 +01:00
select-kit.scss Revert "UX: Open bulk manage tags replace tag choosers above field on mobile (#39632)" (#39782) 2026-05-06 15:49:52 +08:00
single-select.scss UX: Variable additions (#33473) 2025-07-09 18:53:01 -05:00
tag-category-admin-dropdown.scss UX: create combined category and tag settings dropdown (#39099) 2026-04-06 10:09:33 -04:00
tag-chooser.scss FIX: Allow selecting synonyms in composer tag chooser (#39974) 2026-05-22 18:47:59 +02:00
tag-drop.scss DEV: move mobile select-kit CSS to common files (#39055) 2026-04-02 13:46:06 -04:00
topic-chooser.scss
topic-notifications-button.scss DEV: replaces topic-notifications-options by DMenu (#30298) 2024-12-16 19:59:18 +01:00
user-row.scss