Problem/Motivation
If a field contains any nested attachments (#attached), they are lost when rendering a field after a Quick Edit save. This is due to a renderRoot call in \Drupal\quickedit\QuickEditController::renderField(), which renders the absolute markup of a render array without bubbling its attachments to the response.
Replicating this is a little tough without installing Demo Framework (which is where I see this issue), but you should be able to see the problem by adding drupalSettings to a Field Formatter's viewElements function. Something like:
$elements['#attached']['drupalSettings']['foo'] = rand()
Then in your Javascript console, look for the value of 'drupalSettings.foo' as you use Quick Edit. It should change (to a random value) when the field is saved and re-rendered, but is not.
Proposed resolution
Call render instead of renderRoot, which should allow for the attachments to be reflected in the response.
Remaining tasks
Review the patch, possibly write test coverage or postpone this until #2828528: Add Quick Edit Functional JS test coverage is resolved.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| quickedit-render-field-attachments.patch | 571 bytes | samuel.mortenson |
Comments
Comment #3
cilefen commentedThe title is a bit scary. Is it more accurate to say the attachments are "not displayed" rather than "lost"?
Comment #4
samuel.mortensonComment #5
samuel.mortenson@cilefen Should be a bit clearer and less alarmist now. :-)
Comment #6
wim leersComment #14
spokjeDue to Quickedit being moved out of Drupal Core and into a Contrib Module, moving this issue to the Contrib Module queue.