Needs work
Project:
Entity Browser
Version:
8.x-2.x-dev
Component:
Widget plugins
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Feb 2017 at 17:32 UTC
Updated:
9 Apr 2026 at 01:26 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
slashrsm commentedComment #3
marcoscanoI can confirm as of today this is still reproducible with latest -dev of all modules involved.
Comment #4
rwam commentedI stumbled across this issue and can confirm, that this is also a bug on the 8.x-2.x branch.
Comment #5
oknateI can confirm this is still an issue on 8.x-2.1.
The issue is here:
if ($item == $id && $index == $row_id) {this condition is never met after reorder, because the $row_id isn't updated, but the entity id is.
The row_id is an attribute on a dom element and isn't passed in the form data.
If there were no duplicate entity ids, this would work:
if ($item == $id) {But unfortunately, if someone selects the same entity three times and reorders them and tries to delete the 3rd one, it would give unexpected results.
I think the proper solution is to add a weight form element.
Comment #6
oknateI believe this is fixed in latest patch here: #2973457: Add option for field widget to display as table. Closing this issue in favor of that one. If you can help review that issue, please do. I don't think we can fix this properly without adding weight form field to each item, and that's a larger change.
Comment #7
oknateReopening as it may take a very long time before #2973457: Add option for field widget to display as table is merged in. I'll see if I can fix this separately.
Comment #8
oknateComment #9
oknateI've been working on this bug. It seems there is a mix of using the data-row-id attribute to find the correct element to remove and using the 'target_id' element, and after sorting if you press remove, the data-row-id is wrong. Sometimes, it can't even find the correct triggering element: #3046416: Remove button conflict wrong triggering element
I was working for a while to add a 'weight' property, like the file widget has, but it's very tricky with the behavior changing depending on the context, and the entity browser returns data to the 'target_id' element. So there is a lot of code switching it back and forth and detecting when to use the current items' weight fields and when to use the 'target_id'. I think I've hit on a good solution, which avoids the problem, which is to always use the 'target_id' element, and remove the ajax update when pressing the remove button. The remove button can just update the 'target_id' element. Then there is no problem with the current items changing on a rebuild, which is causing this bug: #3046416: Remove button conflict wrong triggering element.
https://www.drupal.org/files/issues/2019-04-25/3040309-38.patch
After lots of trial and error and testing, this allows simplifying the logic in the field widget and removing a lot of the alternate ways of retrieving the data, which is where some of the bugs have come from.
We can drop this:
and this:
Also, this code is unnecessary:
As it can be simplified to:
I decided to drop the buggy getEntitiesByTargetId
and I replaced it with this code:
I think this might need a bit of an update, since I dropped the NestedArray::keyExists. I might just put the function back and update it.
By eliminating the ajax submit of the remove button, we can remove this:
And a few other lines that refer to the remove button. I leave the remove button submit handler there and deprecate it, also, it's still being used by the replace button, so I should probably remove the deprecation.
I noticed that the 'target_id' element has an ajax submit handler, but didn't have a '#submit' method, so I added it:
And a callback:
I believe this helped to remove the stored ids code:
I need to go back and do some testing to see when this callback is called, so I can explain it better.
Here's the new javascript code that handles the item removal on the front-end:
And, I moved code that changes 'target_id' on the front end out of Drupal.entityBrowserEntityReference.entitiesReordered and into a new function, Drupal.entityBrowserEntityReference.updateTargetId, so that the remove buttons can call it too.
I don't think this is necessary any more, as I dropped the weight and target_id in each .item-container, that I had been working on:
So I'll undo that change.
I added this so that as the items are re-ordered, the file widget will update the weight of each item. Otherwise they got out of sync. This is code I was using in the field widget when I was testing adding a weight field, but I was using 'weight' instead of '_weight'. I changed it be consistent with the existing naming convention in the file widget.
Comment #10
oknateHere's patch that updates the entity browser widget to simplify the logic of how it updates after ajax buttons and submit buttons are pressed. Most importantly, it removes the ajax submit for the remove button and replaces it with a javascript method that updates the 'target_id' element.
This circumvents the issues around the remove button triggering element disappearing when the form rebuilds.
This patch depends on #3046416: Remove button conflict wrong triggering element, therefore I'm testing a combined patch.
Comment #11
oknateOops. The combined patch was incorrectly created. Here's an update.
Comment #12
oknateHere's a video of the new behavior. The noticeable differences are:
https://www.drupal.org/files/issues/2019-04-26/sort-plus-delete-update.mov
Comment #13
oknateComment #14
oknateMarking needs work, as I noticed a few things, see my notes above in comment #9.
Comment #15
oknateIgnore this one.
Comment #16
oknateComment #18
oknateThe same as #11, except I undid this change:
Comment #19
oknateHere's test coverage. I tried to mimic the test case in the issue summary as closely as possible. The patches includes 3046416, so if that gets merged first, this will need a reroll.
Comment #20
oknateHere's an interdiff between #18 and #19. I didn't change the fix at all, just added test coverage.
Comment #21
oknateWe still need test coverage for drag and drop, and drag and drop and then remove when using the entity_browser_file field widget, although that could be a follow up.
Comment #24
oknateAs I was trying to fix this schema issue that was causing #19 to fail, I noticed that the EntityBrowserWebDriverTestBase is already setting up the article content type very similarly to the new content type I was creating. So I updated the test to use that one, which means less new configs, and should fix the error in #19. The patches includes 3046416, so if that gets merged first, this will need a reroll. Or we can just merge this one.
Comment #26
oknateAdds coverage for entity_browser_file field widget.
While working on this, I noticed another bug:
#3051318: keying on entity id in entity_browser_file causes item not to display.
I added a fix in this patch, by changing the entity_browser_file current items to key on delta instead of entity id. This is something I've changed back and forth a few times. While I think delta is better and matches the entity_browser_entity_reference field widget, I didn't want to make unnecessary changes. But now, I think, it's necessary to prevent this newly discovered bug.
Comment #29
oknateoh yes, I forgot to update delta in ImageFieldTest from entity-based to delta-based. I had already updated this in another test and can copy it over.
Comment #30
oknateComment #32
oknateOK, so this now has test coverage for both widgets, and I think a good solution.
Additionally, this provides test coverage for drag and drop functionality that was largely missing before.
Comment #33
alonaoneill commentedExtra spaces should be removed
Comment #34
oknateFixing spacing, per #33.
Comment #35
oknateFixing the spacing a bit more. There were some tabs that needed to be replaced by spaces.
Comment #36
kellyimagined commentedRTBC, the solution in #35 fixes the issue.
Comment #37
samuel.mortensonMy local machine is segfaulting when testing any Entity Browser things right now (!!!) but the code seems OK.
Just one note:
Not sure what this has to do with this fix, but if you've tested the limit validation errors addition you made then I'm OK with simplifying here.
Comment #38
oknateThat was part of my effort to simplify the widget. But now that you point it out, anyone extending the module and still using the remove ajax would still want that, so maybe better to leave it in and mark it a deprecated.
Oh, and thank you for testing!
Comment #39
oknateActually, with the limit validation errors, that should be unnecessary, so leaving that change in.
Comment #42
oknateCommitted, thanks.
Comment #43
oknateComment #44
oknateGiving credit to kellyimagined for helping to test.
Comment #47
oknateI reverted this change.
See #3053126: Entity reference widget remove button's new behavior uses too strict selectors
@hctom found a bug that when you add a single item and remove it, the Select Entities button no longer appeared, so you were no longer able to select a different item.
So the no ajax approach needs to be dropped or reworked.
Comment #50
oknateThe tests were failing after reverting the change. I tracked it down to one additional change that needed to be reverted.
Comment #51
oknateHere's an updated patch.
It adds a fix and test coverage for the bug found by @hctom in the original patch. If the number of selected items is equal to the cardinality and the selection mode isn't edit mode, the entity browser element is hidden. So we need a way to bring back the 'Select entities' link or button when an item is removed. I still think the non-ajax method is better, but to restore the entity browser form element, I think we need to do an ajax refresh. So I added code that handles that. If the number of selected items drops below the cardinality and the entity browser element isn't visible, I trigger an ajax refresh to restore the entity browser element, i.e. 'Select entities' link or button.
I added test coverage for two scenarios:
I also incorporate fixes suggested by #3053126: Entity reference widget remove button's new behavior uses too strict selectors. The biggest one, and one that could break BC for people extending the widget is I'm using a new data attribute to select the entities-list.
I could possibly drop this change, but I don't like using the field name in the selector, because we're using this for EntityReferenceBrowserWidget, FileBrowserWidget and when it's ready, the TableWidget (#2973457: Add option for field widget to display as table). Although this might break the remove button for developers who extend these widgets (it would if they replace the entities list element), I think '.entities-list .remove-button' is not namespaced well, and I think this is a good change to make.
If a developer replaced the entities list in a subclass, they probably replaced the remove button too, so they would have an ajax remove button.
If you feel differently, and that we should use '.entities-list .remove-button', let me know, or if you have a better idea.
The change in question is just to add a data attribute to the .entities-list wrapper:
The logic added to fix the bug is to trigger an 'entity_browser_value_updated' event if the number of selections dips below the cardinality:
Comment #52
oknateMinor coding standard fixes.
Comment #54
oknateComment #55
oknateComment #56
oknateUser hctom tested #52, see https://www.drupal.org/project/entity_browser/issues/3053126#comment-131....
Comment #57
marcoscano#52 doesn't apply anymore, here's a re-roll.
Comment #58
marcoscanoI glanced over the patch, but realized that it touches parts of the code I'm not very familiar with, and I recognize I don't fully understand all modifications going on here... :(
I tested it however, both manually and triggered our suite of automated tests (in our current custom project) with the patch applied. We aren't really doing any fancy re-ordering in the entity-reference widget, but we do have several tests interacting with the widget, so at least it's good to hear that all green here.
Nice work!
Comment #59
oknateThank you for testing! I hope that after this issue is resolved, the field widgets will be much simpler.
Comment #60
oknateReroll against current head 52b48b1571d6f8924b5c8bafebe9882ee10f782e.
Comment #61
volkerk commentedI updated #60 to make enitiy_browser work with inline_entity_form again, now checking for values and inputs. The code should now have minimal side effects.
Comment #62
oknateNeeds a reroll @volkerk.
Comment #63
volkerk commentedRe-rolled #61 (applies to 8.x-2.2).
Comment #64
berdirTested this, it also fixes the File entity browser widget with the prepend mode. However, it also breaks the file entity browser widget visually pretty badly.
The patch adds the item-container to the tr, and as a result, the CSS appies and makes this a display: inline-block, which looks then completely broken.
I was able to fix it by changing the CSS like this:
However, custom CSS might be affected too and I think it might be better to add a new class to both widgets that does not yet exist, possibly with a js- prefix? Or a data attribute? See https://www.drupal.org/project/drupal/issues/2431671, don't really know anything about this stuff :)
Comment #65
mtodor commentedI have also tested this patch in Thunder. And it works great!
Comment #66
berdirSetting to needs work for #64.
Comment #67
volkerk commentedUnfortunately I found a regression regarding the new remove button handling.
* Create node type with a entity reference media field, set field required.
* Use entity browser widget, enable "Rendered entity" entity display plugin, enable "Display Remove button"
* Create a new node, select an image using entity browser.
* Click remove button on image.
There are two error messages, it is not possible to remove the image.
The remove button mechanism was switched from having its own ajax submit callback to removing the value via javascript and using the hidden target_id element to submit.
Unfortunately, this means form validation will try to validate a form without existing target_id value, which fails and therefore submit callback is not executed.
The ajax callback then returns the unaltered form, where the last reference is still shown in current but not target_id value is set.
This problem is reproduceable on required fields and fields using the inline_entity_form entity display plugin.
While using the stand-alone ajax submit button, the value was removed on server side after validation.
I reverted the remove button mechanism to its previous behaviour.
Comment #68
oknateComment #69
rachel_norfolkretagging
Comment #70
rogerpfaffThe patch here is provided with the distribution thunder and the widget deletes all entities in a reference field. See #3099950: Entity Browser deletes all entities instead of one for some animations showing the problem. So I tested on a blank drupal with the patch 2851580-67-stable and it's deleting all selected entities when deleting one.
Comment #71
oknateNone of the patches apply right now, so it needs:
I'm thinking we might want to break this up too, since it's a large patch.
Comment #72
shubham.prakash commentedAdded reroll.
Comment #73
abhou commentedThe issue I am having is not being able to delete items from a list of items. When I click on remove button for the first time, it works, but in the second time it roll back the deleted item.
I was able to solve the problem by applying the patch in comment #6 provided in https://www.drupal.org/project/entity_browser/issues/3068327.
Still have a problem after re-ordering and trying to remove an item.
Comment #74
daniel.bosenAnother reroll.
Comment #76
daniel.bosenAnother reroll, now directly from #63
Comment #78
daniel.bosenIt's was the same file ...
Comment #79
daniel.bosenComment #80
daniel.bosenFixing the test.
Comment #82
daniel.bosenI have no idea on how to fix the test. On my local installation, the test does not fail. Maybe this is due to different versions of chromedriver on testbot.
@berdir: regarding #64, I am not sure how to reproduce this. Maybe I am looking at the wrong thing, but file entity browser widget seems to look fine for me.
Comment #83
daniel.bosenAfter some lesser headaches, I was able to get drupalci run locally, this new patch does not fail there as well. Let's see, what the official tests are thinking about it.
Comment #84
daniel.bosenComment #85
fredysan commented#83 worked for me to solve a different issue that occurs when updating an image on a media image field inside layout builder. Basically you couldn't Select an image or Upload a new one after hitting the Remove button and then hitting the Select Media button.
Comment #86
chr.fritschI am trying to reroll this. It's not easy. Let's see what the testbot thinks...
Comment #88
chr.fritschHopefully, this will fix the tests.
Comment #89
fagoI just ran into this issue on a client site, based upon thunder, which uses patch #88. For that site the removal of items broken when updating to thunder 3 and this patch.
The site has extended the entity browser and customized this logic, so it's even another layer more complex. On that site, for some reason the jquery behavior is not fired, so it's submitting via a regular drupal ajax. I must say, I think this patch seems unnecessarily complex:
- why have another drupal behaviour that just triggers another drupal ajax once again? seems an unnecessary complication layer when just directly ajax can be triggered
- generally, that \Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget::formElementEntities $is_releveant_submit detection seems wrong. It's the job of the submit callback to do changes and to handle button specific logic.
- The button specific logic should update form values as suiting for the button logic, e.g. re-order or remove items. Then in formElementEntities() all we need to do is check whether form values (from a form rebuild) are available and use them.
I got my complex use-case working with a custom #ajax button handler and a bit off additional logic in formElementEntities() to apply form values. I'm attaching that additional hunk here. I think with a hunk like that the whole $is_relevant_submit can and should be dropped.
Unrelated, the following hunk of formElementEntities also seems useless, is that really needed?
Going with the pre-existing $items should be jsut fine if no form values are provided imo.
Comment #90
jonathanshawThis patch solved another issue for me:
- a node references a media, using IEF and IEF preview widget from IEF preview module
- the media has a file field, using File EB widget with a custom EB widget to select files from S3 and create file entities
- creating a media and selecting a file worked fine
- but if (before saving the node) I try to click "Edit" to edit the newly created inline media, the EB File widget says "No files yet"
Debugging I found that:
- when I pressed the "Create" button in the IEF to finish creating the new media, this triggered a rebuild of the EB element but with no $items
- this resulted in an empty array of entity ids getting stored into the uuid:field form state key
- when I went to edit the inlne entity, that empty array overrode the actual $items when getting the form element entities.
Comment #91
sinn commentedPatch #88 works for me to resolve https://www.drupal.org/project/entity_browser/issues/3068327.
Comment #92
sinn commentedSolution #88 doesn't work if EntityReferenceBrowserWidget is used in the required field that is shown inside Paragraph Classic or Paragraph Experimental widgets - when I want to remove item validation error `@name field is required.` is shown. But it works well inside Inline Entity Forms widgets.
Schema:
Node -> Paragraph (Paragraph Classic or Paragraph Experimental widgets) -> Entity reference field, required (EntityReferenceBrowserWidget) - doesn't work, validation error.
Node -> Paragraph (Inline entity form - Complex, Inline entity form - Simple widgets) -> Entity reference field, required (EntityReferenceBrowserWidget) - works.
Possible solution is attached.
Comment #93
joevagyok commentedTested #92 and it fixes the original issue and the problem with the required field in paragraphs that was discovered in #88. Thanks @sinn!
Comment #94
arshadkhan35 commentedI have applied patch #92 , but it introduces another issue with layout builder that is if we add a block with entity browser media field and add media item then save, if we edit the block and try to remove media item, the ajax on remove button does not work.
Steps to reproduce:
It seems like in the patch the #ajax for removed button is removed,
Comment #95
rikki_iki commentedThe patch in #92 also resolves https://www.drupal.org/project/entity_browser/issues/2685029.
I also can't reproduce the issue described in #94. The entity browser remove button on a layout builder custom block with media reference works fine for me with this patch applied.
Can anyone else confirm this?
Comment #96
ricovandevin commentedWe are experiencing the same issue as mentioned in #94. The ajax on the remove button is not working anymore after applying the patch.
Update
In our case the issue seems to occur in Safari but not in Chrome.
Update 2
It apparently was a very local issue (i.e. only in one specific browser window). Removing some stuff from the browser cache solved the issue. Confirmed the patch is working both in Chrome and Safari now.
Comment #97
froboyI ran into the exact same issue as @ricovandevin but the patch eventually worked to resolve #2685029: Ajax error when clicking select files within IEF referenced entity. I had to open a completely new session or delete the local/session storage from Dev Tools for the changes in the patch to work. @arshadkhan35 might want to retry.
Comment #98
mxh commentedPatch #92 needs a reroll against 8.x-2.8.
Comment #99
sinn commentedPatch #92 is still applied on 8.x-2.8
Comment #100
mxh commentedok, then something went wrong on my side, setting back to NR.
Comment #101
dave reidI was running into an issue with having a multiple-value Paragraphs with an Entity Browser widget, causing the loss of a newly-selected entity when I got to click the "Add another item" button to add another paragraph item, and this patch seems to resolve it. I wonder if I could pull out a subset of the patch that applies to that issue, because this conflicts with another patch we have applied on our project for the configurable form mode (#2821917: Allow the edit button's form mode to be selected in Entity Browser field widget settings).
Comment #102
anton4uk commentedAdapted patch #92 with patch from #2821917: Set form mode for edit button
Comment #103
joevagyok commentedPlease, whoever contributes to the issue, maintain order and don't introduce mess.
If you provide a patch, please make sure to provide interdiff with an explanation what was changed, and make sure the patch applies without errors and tests are passing.
#102 does not apply, needs work, plus it extends the scope with the issue: #2821917: Set form mode for edit button. I restore #92 the last stable patch into the list as it is in scope of this issue only.
Comment #104
bburgAttached is a rebase of patch from #92 onto the latest 8.x-2.x, as that batch no longer applied cleanly on the 8.x-2.9 branch.
Comment #105
bburgActually, disregard that, I think I have some multiple conflicting patches.
Comment #106
svdhout commentedUpdated the patch in #92 to no longer use jquery once so that it can be used in D1O
$(this).once('entity-browser-remove').on('mousedown', function(e) {becomes
$(once('entity-browser-remove', $(this))).on('mousedown', function(e) {Comment #107
joevagyok commentedThe patch is broken, has indentation issues from top to bottom. The CI also fails to apply. Please make sure to check before upload. I kindly refer to the #103 comment here.
Comment #108
svdhout commentedUpdated the patch, and provided an interdiff
Comment #109
borisson_Correctly applied the patch in #108, there was some context moved in between the patch this was derived from and the current HEAD.
Please don't credit me for this trivial change.
Comment #110
weekbeforenextI tried applying the patches in #92 and #108 to version 2.9.0 of entity_browser and Drupal 9.4.12. Full disclosure, the field I tested with is also using a field widget from entity_browser_table version 1.4.0.
For both of these patches, editing a node and adding a new entity reference to a field with existing references caused the order of the references to change, which I don't think is expected.
Comment #111
agentrickardThis has some overlap and potential collision with #2973457: Add option for field widget to display as table. It would be best to settle on one solution.
The table layout approach is cleaner.
Comment #112
neclimdulI was running into something that seemed similar to this where just having a single field was broken in d10. both replace and remove buttons triggered this error:
Since this looked similar I applied it and it helped but I noticed a couple our weird things with the replace button.
1) Most of the time it just breaks with the same error.
2) Sometimes it seems to replace the current widget with a different entity reference from the page.
The primary field being tested is a media entity using a media entity browser with a cardinality of 1.
Not sure if this even is the right issue but if it is let me know if there are things I can help test to finalize this.
Comment #113
skipvth commentedPatch #108 works for me. Tested in Drupal version 9.5.9 and Entity browser 2.9.0
Comment #114
weekbeforenextThe removal of this code is causing the "Remove" button to not work properly on my site.
Comment #115
acbramley commentedThis fixes another similar issue where if you Add a new item from the browser and then try to remove it, it relaunches the browser.
Also much nicer UX as it appears to remove things straight away.
Tested with an overly complex data model of: Node -> Custom entity form with IEF -> Paragraph -> Paragraph -> Entity browser widget multi cardinality field for a custom entity.
Tested adding, removing, reordering, and tried my best to break it but it all worked well.
Comment #116
weekbeforenextFigured out the issue I reported in #110.
I'm using the Entity Browser - Table Layout project, which extends the EntityReferenceBrowserWidget.php plugin. The changes from this issue caused breaking changes for the other module's widget.
I created a child issue in that project to provide necessary changes if you apply this patch and are also using that module: #3395042: Re-order + remove broken with the Entity Reference (and Table) widget.
Comment #117
joevagyok commentedA new release is published and the dev branch is changed.
I re-rolled #109 patch in order to apply to the latest release and the 2.x dev branch.
Comment #118
dave reidCan we get a merge request version posted so that we can start running the new GitLab CI testing against this?
Comment #120
joevagyok commentedOpened a merge request with the patch from #117. However, I am leaving the patch for composer patching.
Comment #121
joevagyok commentedPlease note that, tests are failing on core v9.5 which I am not sure how relevant at this point, since it will not be supported further I believe. I leave that to the maintainers.
Comment #122
joevagyok commentedAnd as for the test failures with ajax, see this change record. We also started to have the same failures, and we are asserting on elements appearing on the screen instead of using
waitForAjaxToFinish().Comment #123
recrit commentedAdded the latest patch for the MR for composer builds
Comment #124
bunty badgujar commentedAfter using the above patch with Drupal 10 + layout builder, I am getting the following error
RuntimeException: The subform and parent form must contain the #parents property, which must be an array. Try calling this method from a #process callback instead. in Drupal\Core\Form\SubformState->getParents() (line 76 of /Users/maria.mcdowell/Sites/devdesktop/eemmcdowell-test/docroot/core/lib/Drupal/Core/Form/SubformState.php).I have created a separate issue with all the details "Error when trying to place a new block: RuntimeException: The subform and parent form must contain the #parents property, which must be an array."
Updated patch #123 to fix the above error.
Comment #125
edmund.dunn commentedThis one worked for us!
Comment #126
berdirD11 tests are failing atm, but 10.4 and previous major tests should be passing.
Comment #127
almunningsWas seeing some issues with the Gin admin theme. Worked on in Claro.
When the entity references render as a table, gin wraps the table in 2 div elements. Removing those divs, it all worked again.
Unsure if this is immediately related, but combining this patch plus:
Has restored functionality in the Gin admin theme.
Comment #128
joevagyok commentedRe-roll over latest 8.x-2.x.
Comment #129
vasyok commentedThanx, @joevagyok. Your patch is necessary!
Comment #130
inregards2plutoWe just encountered this issue on our Drupal 11.2.8 site when we had a combination of a LB SDC + an image field using a custom entity browser.
I applied this patch and it fixed the issue for SDCs using standard fields (e.g. an Image SDC with a single image field that uses entity browser), so that's good.
However, if the SDC uses a complex field type (e.g. Custom Field), there are issues. For example, there is a SDC called "Card Group" and within that SDC there is a Custom Entity Field field type for individual cards. Each card has its own image field. When using the block configuration form in Layout Builder, the image in the first card entry successfully removes and re-adds the image, but the second card on still displays the original issue.
Note that there are no issues with adding an image for the first time to any of the Custom Field nested fields. This is specifically when removing an existing image and trying to re-add a new one.
I'm certain this is just a matter of updating the patch to account for the nested structure of Custom Field field types, but did want to flag it here for others who might be using entity browsers within Custom Fields on LB.
Comment #131
inregards2plutoBelay that last comment. Looking back at the Custom Entity module, I see that custom_field_entity_browser uses a modified COPY of the EntityReferenceBrowserWidget, so my issue might fall more on the Custom Entity module having an outdated copy of the EntityBrowserWidget.
Ignoring the Custom Field problems, the patch worked for me :)