Skip to content

[4.x][5.x]: Unable to expand/collapse entry/category in field element select modal if descendant already selected for field #15337

@ttempleton

Description

@ttempleton

What happened?

Description

When a descendant element is set to a categories field, or an entries field set to maintain hierarchy, the element's ancestors can't be expanded or collapsed in the element select modal. This creates a problem if the ancestor is stuck as collapsed (which can happen if it was collapsed when the field was used in a different context where the ancestor was collapsible), since no other descendants can then be selected for the field.

Steps to reproduce

  1. Fresh Craft install
  2. Create a new new category group, or structure section, with no level limit
  3. In the above group/section, create one level 1 element (named L1) with two child elements (named L2A and L2B)
  4. Create a categories or entries field with the above group/section as its only source, set to maintain hierarchy, no limit on selectable branches
  5. Create a channel section (and entry type on Craft 5), and add the above field to the entry type field layout
  6. Create an entry in the channel, add element L2A to the above field
  7. Try to add another element to the field, and note that element L1 cannot be collapsed
  8. Create another entry in the channel, click to add an element to the field, collapse element L1 and exit
  9. Go back to the first entry in the channel, click to add an element to the field, and note that element L1 cannot be expanded, making it impossible to select element L2B

Expected behavior

Category/entry could be expanded/collapsed regardless of any descendant elements being selected for the field already

Actual behavior

Category/entry can't be expanded/collapsed

Craft CMS version

4.10.5 / 5.2.6

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

None

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