feat: #3061562 Keep the widget on the input so other code can reach it
Issue: https://www.drupal.org/project/autocomplete_deluxe/issues/3061562
The behaviour built the widget and threw the instance away, so nothing on the page could add a value from JavaScript, which is what a list of terms beside the field needs to do.
The widget is now kept in the jQuery data of the input:
jQuery('#autocomplete-deluxe-input')
.data('autocompleteDeluxe')
.addValue({ label: 'Drupal', value: 'Drupal (7)' });The value is the same Label (id) pair the field stores, so the tag, the hidden value and the saved reference all line up.
Tested on Drupal 11.4: two values added that way appear as tags, the hidden field reads ""Drupal (7)"" ""Design (9)"", and saving the node stores term IDs 7 and 9.
AI-Generated: Yes
Checkpoints:
- File an issue — issue #3061562
- Addition/Change/Update/Fix — the widget object is put on its input
- Testing to ensure no regression — whole suite green, 36 scenarios
-
Automated unit testing coverage— nothing pure to unit test, the change is a browser behaviour - Automated functional testing coverage — 2 scenarios, both fail without the change
- UX/UI designer responsibilities — nothing visible changes
- Readability — phpcs, eslint and stylelint clean
- Accessibility — no markup, focus or ARIA change
- Performance — one property assignment per widget, no new request
- Security — no access, output or query change
- Developer Documentation — the handle and its use are documented in the code
- User Guide Documentation — nothing an editor sees
- Reviewed by human
- Code review by maintainers
- Full testing and approval
- Credit contributors
- Review with the product owner
- Release notes snippet
- Release
Edited by Rajab Natshah