Needs work
Project:
Drupal core
Version:
main
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Feb 2014 at 00:43 UTC
Updated:
20 Mar 2025 at 10:54 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #1
zyxware commentedThe data returned has label and values as key value pairs as an array of objects and showSuggestions was still searching for values in an array. The attached patch checks for existing terms in the value property of the objects returned and splices such objects from the array.
With the patch applied I see an anomaly in how the logic works.
Suppose the field already has bar in the value (with bar and baz as valid items in the term database) and I type in 'ba' the autocomplete comes up with 'baz' and no 'bar'. This is alright. I then pick 'baz' and type 'ba' again, no autocomplete comes up as both 'bar' and 'baz' are in the line. Now I backspace and remove both 'bar' and 'baz' from the box. I type 'ba' again and don't get anything. The suggestions for 'ba' are cached locally and not recalculated locally again. Not sure if that is the right way to do. Shouldn't just the original return values from the server be cached and recalculations always done against current items in the text box?
Comment #3
wim leers1: core-js-ui-autocomplete-2186647-1.patch queued for re-testing.
Comment #4
amateescu commentedRe #1: Yes, it seems that the local cache for autocomplete suggestions is a real problem. Talked about it with @nod_ in IRC and he said it's okay to remove it, but let's get an official response here as well :)
Comment #5
droplet commentedIt's all we have to do. Use jQuery UI function, easy life :)(I'm confusing myself, skip this patch, thanks)Comment #6
droplet commentedReroll patch #1
Comment #8
droplet commented6: core-js-ui-autocomplete-2186647-6.patch queued for re-testing.
Comment #9
nod_looping over an array that changes it's length is dodgy.
We can do the same without messing with the length and splice.
Comment #10
nod_Comment #11
nod_Comment #12
amateescu commentedI thought we agreed to also remove the client cache in this patch?
Comment #13
droplet commentedBoth patches removed the first suggestion.
For example, you have "Kay" in the Tags terms list, You type in "Kay", no suggestions
Comment #14
droplet commentedComment #23
rahul.shindeI have re-rolled the patch.
Comment #24
nod_There are better array functions these days, includes is not supported an IE so let's use .find() instead for which we already have a polyfill.
Also please check out this page: https://www.drupal.org/docs/frontend-developer-tools-for-drupal-core you should not edit directly the .js file. The workflow is to edit the *.es6.js file and generate the *.js file afterwards. There is a warning on top of every JS file, check it out.
Comment #25
rajneeshb commentedI have re-rolled the patch and cover the all points of #24
Comment #27
anmolgoyal74 commentedComment #28
ranjith_kumar_k_u commentedThe above patch works fine,it resolves the issue.

before applying the patch
after
Comment #30
tanubansal commentedTested #27, working fine on 9.1
This can be moved to RTBC
Comment #31
abhijith s commentedThe patch #27 works fine.


Including screenshots
before patch:
after patch:
RTBC
Comment #32
amateescu commentedI think #4 still needs to be addressed, right?
Comment #35
vikashsoni commentedApplied #27 patch applied successfully and looks good for me
After patch not able to select duplicate entry in autocomplete
for ref sharing screenshot ....
Comment #38
mstrelan commentedI think the changes requested in #24 can be reverted now that we don't support IE anymore. As mentioned in #32 we still need to address #4.
Comment #39
acbramley commentedConfirmed the issue still exists on 10.1.x. The same solution should be able to apply, but we need tests and a reroll as well as removing the local cache.
Comment #40
karishmaamin commentedRe-rolled #27 patch against 10.1.x.
Comment #41
rishabh vishwakarma commentedAdding reroll for 10.1.x. Patch #27 throws the following error -
error: patch failed: core/misc/autocomplete.js:65
error: core/misc/autocomplete.js: patch does not apply
Comment #42
smustgrave commentedStill needs tests
Comment #43
nitin shrivastava commentedFix CCF errors.
Comment #44
nitin shrivastava commentedComment #45
mstrelan commentedMy suggestion in #38 was a little misguided. What I meant is that we can indeed use
includesinstead offind.Comment #46
rishabh vishwakarma commentedAdded changes according to #45
Comment #47
rishabh vishwakarma commentedComment #48
acbramley commented#46 doesn't fix the bug, and still needs tests.
Please guys, do not reroll or make changes to this patch if you're not going to properly test the functionality fixes the bug or read any other comments in the issue.
Comment #49
acbramley commentedHere's a working fix with .includes. Still looking for existing JS tests for this widget but I don't think there are any.
Comment #53
akalam commentedI've created a MR with the changes of #79 to apply against D11 or D10.4. I've tested the patch locally and it works avoiding to display terms alreay applied when using an entity reference field with the widget "Autocomplete (tag style)"