Skip to content

[5.x]: Category Selection Always Overwrites #14872

@theAdhocracy

Description

@theAdhocracy

What happened?

Description

If a category field already has a value selected, and an editor then opens the "Add category" modal and chooses any category, the original value is overwritten. In Craft 4 and prior, the overwrite would only occur if the category field was set to only allow one value. If a one-to-many relationship is allowed, the categories would be added to the existing list.

This may be related, so I'll mention it here as well, but the same issue occurs within the modal when searching, so you cannot make multiple searches to find different categories, as each search deselects previous selections.

Steps to reproduce

  1. Create a category field with no restrictions on number of relationships and implement this on an entry type.
  2. Add a category on an entry of the relevant type and save.
  3. Reopen the entry, press the "Add category" button, select any other category, and press Select.

For the secondary issue:

  1. Reopen the entry, press the "Add category" button, select any category.
  2. Now search for any other category within the modal's search input. Select any returned category.
  3. Press Select.

Expected behavior

Both the originally selected category and new category should be present.

For the secondary issue: both selected categories should now be present (the one selected prior to searching, and the one selected after).

Actual behavior

Original category is removed and only the new category is now visible.

Secondary issue: only the latter will be present.

Craft CMS version

5.0.4

PHP version

8.2.18

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions