Remove button on multi-step display not working with uppercase entity IDs

Created on 8 October 2019, almost 6 years ago
Updated 19 August 2025, about 1 month ago

Probably an edge-case here, but nevertheless a bug AFAICT.

I'm connecting to an external - out of my control - data source using http://drupal.org/project/external_entities. The entity types entities have uppercase IDs. I'm displaying these entities in an multi-step view entity browser.

The "Remove" button on the selected items, however, doesn't do anything - at first sight. If I click it, a temporary AJAX loading screen appears but the item itself is not removed. Only when the page (iframe in my case, displayed in a modal) is refreshed, the item is removed.

I found out that the root cause for this is is that my entities have uppercase IDs. A screenshot of the HTML snippet of an item that has been selected:

As you can see the data-drupal-selector attribute contains the ID in lowercase, while the data-remove-entity attribute contains the ID in uppercase. It appears Drupal always lowercases the data-drupal-selector attribute.

What happens in entity_browser.multi_step_display.js is the following:

var button_element = $(event.target);
var remove_entity_id = button_element.attr('data-remove-entity') + '_' + button_element.attr('data-row-id');

$entities.trigger('remove-entities', [[remove_entity_id]]);

remove_entity_id here has the ID in uppercase. Going further...

// Remove dom element, and queue entity for removal in backend.
var element_selector = '[data-drupal-selector="edit-selected-'.concat(entity_ids[i].replace(/_/g, '-'), '"]');
entities_list.find(element_selector).remove();

element_selector is being constructed with the uppercase ID, but the element will never be found since it exists in the DOM with a lowercase ID.

🐛 Bug report
Status

Needs work

Version

2.0

Component

Display plugins

Created by

🇧🇪Belgium rp7

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024