Problem/Motivation
I have setup a view to show on a node, the view shows an entity with an editable field. This works with render cache disabled, but once I enable the render cache, it works the first time after a cache clear, then the js appears to not work.
Steps to reproduce
- Create a vanilla D10 site
- Install the 1.0.2 version of the module
- Setup a comments block view to use relationships of the content it is on
- Add the block to your pages
- Ensure you haven't got the render cache set to 'cache.backend.null'
- Flush the cache
- Test the fields (refreshing after first success)
Proposed resolution
Investigation then resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | editablefields-ajax-cache-fix-3547146.patch | 4.68 KB | retrodans |
Comments
Comment #2
retrodans commentedIt appears to be something to do with the js line 208 in EditableFieldsForm.php
$js = 'document.querySelector("#' . $wrapper . ' [type=submit]").dispatchEvent(new Event("mousedown"));';
If I run the js in console (after the refresh) the command returns true, but doesn't actually update the form. If I change the code to use jQuery, the form gets submitted ONLY after the refresh, and the whole page refreshes (no nice ajax).
Comment #3
retrodans commentedIt also looks like on the submit button, 'data-once="drupal-ajax"' disappears in the render cache refresh. I am not sure why, but it feels like it might be related.
Comment #4
retrodans commentedThis caused a lot of headscratching, but I think we have a patch which appears to work.
🔧 What the Patch Does
The patch adds these files to the editablefields module:
🎯 How It Works
The JavaScript: