Create an option group when using Select2 in taxonomy select field with multiple vocabularies and enabled autocomplete

Created on 10 March 2023, over 1 year ago
Updated 13 September 2024, 2 months ago

Problem/Motivation

At the moment if you have autocomplete enabled in Select2 and you have selected multiple vocabularies as source when creating a taxonomy select widget it can be really hard to understand where the terms are coming from if there are multiple vocabularies involved.

For example Chosen has an additional setup where it groups the terms by the parent vocabulary by creating an optgroup from the vocabularies. Attached is a screenshot of how Chosen groups them.

It would be really nice if select2 could do the same. There is also a similar Codepen for the feature for Select2: https://codepen.io/doitian/pen/nKBbmz

Steps to reproduce

1. Create a field where you select multiple vocabularies as the source and with a lot of terms.
2. Enable autocomplete for the field.

Select2 just lists the terms in one list at the moment. You can of course filter the list but it's still hard to understand the context of the term without the vocabulary if there are multiple vocabularies involved which would help you find what you are looking for.

Proposed resolution

It would be nice if the terms would be grouped by the parent vocabulary with option group.

Remaining tasks

Implement the logic and tests.

User interface changes

Either add an option to do this in the widget settings are do it automatically.

Feature request
Status

Active

Version

1.0

Component

Field widgets

Created by

🇫🇮Finland heikkiy Oulu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024