Problem/Motivation

During the usability sessions, some participants were confused by the UI of the content reference autocomplete widget. The node ID in parentheses is unclear and in most cases redundant.

Some users removed the ID, thinking that it was a bug or would have a negative effective on the display of the item. Once they removed the ID, the system assumed they were creating a manually entry, and would produce an error on the menu link form.

Huh… I guess you need that.

The node ID is only needed to differentiate between two nodes with the same name. During discussion, we considered this a valid use case.

Proposed resolution

Only show the node ID when there are two results with the same title.
Prefix the value with 'ID:', so it is more clear what the purpose is.

Remaining tasks

Implement the suggestions
Design review
Test

User interface changes

A less confusing node auto complete

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LewisNyman’s picture

Issue summary: View changes
izus’s picture

hi,
here is a patch to add the 'ID:' part

izus’s picture

Status: Active » Needs review
izus’s picture

missed the form validation and display in my last patch
Here it is again

The last submitted patch, 2: Drupal_core-ID_autocomplete-2520416-2.patch, failed testing.

izus’s picture

Status: Needs review » Active
izus’s picture

Status: Active » Needs review

retrigger testbot

Status: Needs review » Needs work

The last submitted patch, 4: Drupal_core-ID_autocomplete-2520416-4.patch, failed testing.

izus’s picture

Status: Needs work » Needs review
FileSize
10.82 KB

Status: Needs review » Needs work

The last submitted patch, 9: Drupal_core-ID_autocomplete-2520416-9.patch, failed testing.

izus’s picture

Status: Needs work » Needs review
FileSize
13.5 KB

Status: Needs review » Needs work

The last submitted patch, 11: Drupal_core-ID_autocomplete-2520416-11.patch, failed testing.

izus’s picture

Status: Needs work » Needs review
FileSize
15.42 KB

Status: Needs review » Needs work

The last submitted patch, 13: Drupal_core-ID_autocomplete-2520416-13.patch, failed testing.

izus’s picture

Status: Needs work » Needs review
FileSize
16.17 KB

Status: Needs review » Needs work

The last submitted patch, 15: Drupal_core-ID_autocomplete-2520416-15.patch, failed testing.

pfrenssen’s picture

There is another reason to implement this: in Drupal 8 entity IDs are not always numeric, they can also consist of arbitrary strings. We will run into problems when we will try to match on IDs that contain parentheses. The solution proposed here will solve that too.

damiankloip’s picture

Version: 8.0.x-dev » 8.2.x-dev

The only trouble is this will need a complete re work of how autocomplete.js works, how field widgets work that will use this (to show a different label to what is submitted), and it will break lots of existing autocomplete callbacks implementations as there is no requirement that they are keyed by entity ID currently.

Moving to 8.2.x possibly, but might not be achievable for that either... Not sure.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

pfrenssen’s picture

Having the entity ID between brackets is also useful sometimes: you might have a bunch of entities with identical titles. Then you can use the entity ID to distinguish between different entities. This is not ideal since the content editors would need to look up and memorize the ID of the entity they are referencing.

Maybe we can implement a new field widget? So we have the standard field widget with the visible entity ID by default, but the site builder can choose to select the widget without ID. This would also solve the backwards compatibility issue with contrib modules that rely on the current behaviour.

pfrenssen’s picture

The node ID is only needed to differentiate between two nodes with the same name. During discussion, we considered this a valid use case.

Thinking a bit further on this, if the entity title by itself is not sufficient to distinguish between two different entities, then we should allow to fully customize the displayed autocomplete values. The ID is very poor to assist with this. It could for example be that the author of the entity is enough to distinguish between two identical titles. Why not show "Identical title (author: Jane Doe)" in this case? There are really nice ways for solving this in a generic way, we could for example provide an autocomplete result view mode!

jibran’s picture

Component: entity_reference.module » entity system

Moving to right component

Berdir’s picture

The widget already supports leaving out the ID *if and only if* there is an exact match for a single entity. Otherwise it doesn't work.

I think this is trying to solve the wrong problem and should be closed as a duplicate of #2346973: Improve usability, accessibility, and scalability of long select lists or a similar issue. When we have a sane autocomplete UI that as a concept of internal key and user-facing label then this problem will simply go away.

Of course, no idea when that will happen, but nothig happened in this issue either for half a year now :)

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Pancho’s picture

@Berdir in #23

The widget already supports leaving out the ID *if and only if* there is an exact match for a single entity.

Does it? I can’t find the UI setting.

@jonathanshaw in #2346973-140: Improve usability, accessibility, and scalability of long select lists

Everyone wants this. But it's not showing any signs of going anywhere.

Agree that it doesn’t seem like we’re getting an autocomplete replacement in core before D9.
So unfortunately we do have to continue fixing the more pressing issues with autocomplete.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

schnydszch’s picture

Hi! Any update to this? Experiencing the same with Drupal 8.8.1.

catch’s picture

Status: Needs work » Closed (duplicate)

Agreed with Berdir in #23, let's concentrate efforts in #2346973: Improve usability, accessibility, and scalability of long select lists.