When trying to quick edit an entity reference field that uses the Drupal\entity_browser\Plugin\FieldFieldWidget\EntityReference plugin for its widget, I've run into two issues:
- #2635712: Cannot use Quick Edit to delete an image : that one will need to be fixed in core. That being said, the patch there fixes the logic exception, which allows us to move forward here.
- Quick Edit only shows its "Save" button when it detects that something was changed by the user. The change to the hidden input used by the widget isn't perceived as a change, and thus doesn't let Quick Edit knows that something changed and needs to be saved. This will need a fix in Entity Browser
I've a patch for the second bullet point, going to upload it as soon as I've got an issue number.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 2733605-11.mov | 4.3 MB | phenaproxima |
| #11 | 2733605-11.patch | 1.54 KB | phenaproxima |
| #6 | interdiff-2733605-4-6.txt | 568 bytes | samuel.mortenson |
| #6 | entity-browser-quickedit-2733605-6.patch | 1.48 KB | samuel.mortenson |
Issue fork entity_browser-2733605
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2733605-quick-edit-compatibility
changes, plain diff MR !131
Comments
Comment #2
DeFr commentedPatch mentionned above.
Not sure yet if entity_form needs the same fix, just thought about it when uploading the patch. Testing.
Comment #3
slashrsm commentedTested and confirmed that it displays "Save" button when appropriate. However, it seems that something is still broken; no matter which operation I do the list of entities in the widget stays the same. When I save it respected the change (added an entity to the list).
Did you also experience that?
Comment #4
samuel.mortensonI did @slashrsm :-)
This patch should trigger the formUpdated event on selection, re-order, remove, and edit events. We could write test coverage for this, but Quick Edit test coverage is really complicated so I'm not sure if it would be worth our time. The functionality of the field widget is tested elsewhere.
Comment #5
samuel.mortensonComment #6
samuel.mortensonDrupal's core AJAX was preventing the click event, so I went with mousedown instead.
Comment #7
samuel.mortensonComment #8
phenaproximaThe code looks pretty good to me. Normally I'd ask for tests, but @samuel.mortenson informs me that Quick Edit itself has no test coverage, and that therefore we can't add tests. That's a Mobius strip argument if I ever heard one ;)
But, tagging for manual testing.
Comment #10
phenaproximaAh well.
Comment #11
phenaproximaI rerolled the patch, but unfortunately this is not fixed for me with 8.6.x HEAD of core and the 8.x-1.x HEAD of Entity Browser.
I set up the most bare-bones Entity Browser setup I could (just added an Entity browser display to the content view), and got this when I tried to Quick Edit a node and remove a referenced article (see attached video).
Comment #12
rpayanmComment #13
benstallings commentedClaude Code says:
One concern with the entity_reference.js changes:
The patch changes the selector from .entities-list.sortable to just .entities-list, and switches from the Sortable library to jQuery UI .sortable(). The current codebase (on 8.x-2.x) uses the Sortable library (line 19), not jQuery UI. This patch appears to be based on an older version of the file. It would conflict with the current code and would need to be adapted to work with the Sortable library's onEnd callback instead.
Verdict: The formUpdated trigger is the right fix — entity browser changes should participate in Drupal's unsaved-changes tracking. The common.js change applies cleanly. The entity_reference.js changes need to be rebased against the current Sortable-based code.
Comment #16
benstallings commentedDisregard my erroneous MR. The patch #11 no longer applies.