Seamless entity reference autocomplete integration

Created on 25 July 2016, about 9 years ago
Updated 9 August 2023, about 2 years ago
✨ Feature request
Status

Needs work

Version

2.0

Component

User interface

Created by

πŸ‡¨πŸ‡­Switzerland miro_dietiker Switzerland

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • πŸ‡ΊπŸ‡ΈUnited States dave reid Nebraska USA

    I think we should try to get the updated for 8.x-2.x.

  • πŸ‡΅πŸ‡±Poland gugalamaciek

    This patch adds one more feature - "Advanced search" link at the end of autocomplete suggestions. When clicked, it opens entity browser.

  • πŸ‡΅πŸ‡±Poland gugalamaciek

    I added preview improvement. So now, when something is selected you can setup preview of it in widget configuration. How it looks like:

  • πŸ‡§πŸ‡ͺBelgium rp7

    Re-rolled against latest 2.x + fixed an issue when copy/paste something in the autocomplete field (this issue was introduced in patch in #31).

  • πŸ‡¨πŸ‡¦Canada man-1982

    Reviewed and tested.
    Drupal 10.3
    MR was applied without any issue.
    Suggest adding MR
    thanks

  • πŸ‡΅πŸ‡±Poland gugalamaciek

    Minor improvement: The preview remove button form #name was not always unique.

  • Status changed to Needs review 7 months ago
  • πŸ‡§πŸ‡ͺBelgium rp7

    Patch in #34 gave me JavaScript issues on Drupal 10.4.6. event.target.preventDefault(); was being called where event.target was undefined. Appeared an issue with the order of JavaScript being loaded. Added small adjusment to make sure the JavaScript is loaded after autocomplete is initialized.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    This functionality would still be really fantastic and a great improvement for Drupal!

    Not being forced to decide for the easy and quick autocomplete widget, if you know the label of an entity, but also having the option to alternatively use entity browser alternatively on the same widget, would be absolutely best for more complex use-cases.

    On top it would be a dream to have the option to create a new or edit the referenced entity in a modal, but that's a different topic. Having all that would make things really complete and useful!

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    PS: Let's switch to using a MR instead of patches! Anyone else interested in pushing this over the finish line?

  • First commit to issue fork.
  • @grevil opened merge request.
  • πŸ‡©πŸ‡ͺGermany Grevil

    This should be it! Please review!

  • πŸ‡©πŸ‡ͺGermany Grevil

    Tests fail because of πŸ› Fix arguments for tests Active .

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • πŸ‡©πŸ‡ͺGermany Grevil

    A few things are still not perfect.

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Based on a very quick test, some first feedback:

    * Doesn't seem to work at all on cardinality 1 fields, I'd want to use this for the paragraphs_library paragraph type, which is one of those. I get a button
    * should use smaller button classes on Claro/gin, they seem huge.
    * add another item and select button to open entity browser are IMHO pretty confusing and not a great user experience. maybe the the entity browser button could be on top, maybe both small next to each other with some guidance on which does what?
    * edit doesn't seem to use the same dialog system as the regular entity browser widget

    (we have the widget pretty heavily customized in our project, with custom edit/delete icons on top of the previews instead of buttons, so I'm not 100% sure if anything affects that, didn't test on plain claro yet)

  • πŸ‡©πŸ‡ͺGermany Grevil

    @rp7

    Patch in #34 gave me JavaScript issues on Drupal 10.4.6. event.target.preventDefault(); was being called where event.target was undefined.

    That is, because there is no event.target.preventDefault(). There is only event.preventDefault(), see https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault.

    Manually adjusting the weight in the library is not recommended and messes with code execution timings, which leads to frustrating debugging sessions. Please avoid it.

  • πŸ‡©πŸ‡ͺGermany Grevil

    @berdir, thanks for the feedback!

    Doesn't seem to work at all on cardinality 1 fields, I'd want to use this for the paragraphs_library paragraph type, which is one of those. I get a button but no autocomplete field

    This sounds weird! I have only tested it with target entity type being "node". Could you test the latest MR, if that is still the case now?

    should use smaller button classes on Claro/gin, they seem huge.

    Definitely. A Colleague of mine could possibly fix up the styling.

    add another item and select button to open entity browser are IMHO pretty confusing and not a great user experience. maybe the entity browser button could be on top, maybe both small next to each other with some guidance on which does what?

    Ok, I'll take a look on Monday.

    edit doesn't seem to use the same dialog system as the regular entity browser widget

    Hm, could not reproduce this behavior, but maybe I misunderstand. Could you elaborate

    Generally feel free to do some final touches here! This was quite the pain to finalize.

    I think the main problem is, that this Widget extends "EntityReferenceAutocompleteBrowserWidget" instead of "EntityReferenceBrowserWidget", and therefore the implementation differs enormously from the original widget.

    But this might have a reason, and I am really thankful that this MR was already this far in development. Thanks all! πŸŽ‰

    Anyway, I think this can get reviewed now. Final touches should still be added. Unsure if we can provide test coverage....

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks @grevil! Great (and really hard) work. Current status attached as static patch.

Production build 0.71.5 2024