Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I have a two level taxonomy hierarchical select that is required and "select deepest level" is also set. Users are selecting the root but sometimes not selecting the next level -- so it defaults to the first in the list, which is not good. I need the first item in the list to say something like Select State in order to get them to actually look at the list.
Is there anything I can do?
Proposed resolution
Add a <Select>
option at every level of a "Force the user to choose a term from a deepest level" field to enforce the user interacts with the full list of options.
Remaining tasks
- Field Config: Add checkbox below "Force the user to choose a term from a deepest level" option.
- Field rendering: Remove current "Force the user to choose a term from a deepest level" UI behaviour.
- Field rendering: If checked add an empty
<Select>
option at the start of each extra selector added. - Field validation: Add validation to check if the selected term has children. Return a form error if so.
User interface changes
- Add a checkbox below the "Force the user to choose a term from a deepest level" option. Call it something like "Force selection at every level".
- Have this inject
<Select>
at the top of extra selects. - Add a field description explaining that they need to select from the deepest level of their selected items?
API changes
None
Data model changes
None
Comments
Comment #2
ShaneOnABike CreditAttribution: ShaneOnABike commentedI agree and am having the same related issue. Essentially, this is a pretty significant usability issue. The selection of terms should not automatically display all the levels below.
For example, we have:
Veggies > Root > Carrots
Meat > Cattle > Free-range
Meat > Cattle > Dancing cows
Meat > Sheep > Make you sleep
If the user selects Cattle it automatically selects Free-range since it's the first in the list. I think from a usability perspective this is confusing. They should just be shown Cattle as they are when you don't force the deepest selection.
So you get
(Select) Meat
(Displays) Meat > Cattle
Then they can choose the next level... I changed this from a support request to a Bug Report since it is a usability issue. As well, increased the Priority since I think that the point of Hierarchial Select is to provide users with a fluent, ease-of-use system.
Comment #3
GoldWhile this is a nuisance it isn't breaking functionality.
I can see workarounds if you are comfortable with writing code though. I've updated the description to reflect this.
The existing behaviour doesn't break the module though so it's not really a Bug Request. My proposed fix is adding to it though which makes it more of a feature request. Given it is very poor UX though I think the priority of Major is reasonable.
Regarding discussion around this though, would we want this to be the default behaviour? It feels like it should be.