Avoid duplicated references

Created on 13 August 2019, over 5 years ago
Updated 4 July 2024, 6 months ago

Problem / Motivation
I have enabled the Entity Browser with version 8.x-2.2. I just added the one result to node and second time the same content can be added. This is duplicate is added because of below code.

Drupal.entityBrowser.updateEntityIds = function (existing_entities, selected_entities, selection_mode, cardinality) {
    var combined_entities;

    if (selection_mode === 'selection_edit') {
      // Propagate new selected entities.
      combined_entities = selected_entities;
    }
    else if (selection_mode === 'selection_prepend') {
      // Prepend selected entities to existing list of entities.
      combined_entities = selected_entities.concat(existing_entities);
    }
    else {
      // Append selected entities to existing list of entities.
      combined_entities = existing_entities.concat(selected_entities);
    }

    // Having more elements than cardinality should never happen, because
    // server side authentication should prevent it, but we handle it here
    // anyway.
    if (cardinality > 0 && combined_entities.length > cardinality) {
      combined_entities = combined_entities.slice(0, cardinality);
    }

    return combined_entities.join(' ');
  };

Please review my patch.
Thanks

🐛 Bug report
Status

Fixed

Version

2.0

Component

Widget plugins

Created by

🇮🇳India iyyappan.govind Chennai, India

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