Problem/Motivation

I have a page with multiple autocompletes. They are displayed in different places so they are styled differently. The only unique attribute was ID, however, it changed paged to page.

Steps to reproduce

Add more than one search autocomplete and you will see #ui-id-1, #ui-id-2, #ui-id-3 etc with no unique/descriptive selector.

Data model changes

I simply added a data-input-ref attribute to the ui-autocomplete that would tell me exactly what input this autocomplete is from. It ends up being the machine name of the autocomplete.

Without the patch you see the rendered autocomplete as:

<ul id="ui-id-1" tabindex="0" class="ui-menu ui-widget ui-widget-content ui-autocomplete ui-front" unselectable="on" data-sa-theme="minimal">
...
</ul>

With the patch:

<ul id="ui-id-1" tabindex="0" class="ui-menu ui-widget ui-widget-content ui-autocomplete ui-front" unselectable="on" data-input-ref="your_autocomplete_machine_name" data-sa-theme="minimal">
...
</ul>

Comments

rondog469 created an issue. See original summary.

dom.’s picture

Status: Active » Needs review
StatusFileSize
new1.32 KB

I am very sorry, but I can't see how this work.
Testing the patch, I have no value.data('id') only possible values are key and drupalSelector here.

Is something like this patch okay for your needs ?

  • Dom. committed 9d740586 on 3.x
    Issue #3318784 by Dom., rondog469: I added a data attribute to ui-...
dom.’s picture

Version: 2.0.2 » 3.x-dev
Status: Needs review » Fixed

Will be added in 3.0 release for Drupal 10.

rondog469’s picture

thank you @Dom! Yeah I am not too sure what I did with that first patch. I think I uploaded the wrong version at the time because it indeed does not work. Yours look good to me

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.