Problem/Motivation
If there are any autocomplete form input elements that define a data-autocomplete-first-character-denylist attribute, this attribute will be used on all autocomplete elements. If there are multiple autocomplete elements with different denylist values, only the last one will be appied to all elements.
This is because there is a single denylist is set in the global autocomplete.options by iterating thru the autocomplete elements.
Steps to reproduce
- Create a node with a title that contains a / in it.
- Create a content type with an entity reference field for nodes.
- Add a links field
- Set the node field to use the autocomplete widget
- Create a new node of the content type
- In the node reference field enter a / as the first character
- The node with a / in it will not show. Typing more characters will not autosearch
- This is because the link field has a data-autocomplete-first-character-denylist attribute.
An alternate but more complex test is:
- Use the same set up as above.
- Create a entity reference view that uses the title and and link to content
- Make sure to search both fields in the settings
- Change the node reference field to use this view
- Create a new node
- Try finding a node using the path to the content
Proposed resolution
The autocomplete.js searchHandler method needs to get the event target's denyList attribute and not use the global option value.
Additionally, the code to set the firstCharacterDenyList option should be removed.
Remaining tasks
Make the changes.
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3622108
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
hoxton commentedUsing per element first-character-deny-list.
But still using global isComposing flag.
Comment #5
hoxton commentedComment #6
smustgrave commentedCan we get a test showing the issue.