Overview
When you're editing an entity and make changes to the page data form fields, these are saved in auto-save
If you reload the page the form doesn't reflect the values in the auto-save store
Steps to test
Enable xb_test_article_fields module and add an article node
Edit this article in XB and click 'Add another item' on the multi value text widget.
Populate the field.
Wait for the autosave to be stored (the review changes button will become active)
Reload the page and note that you're back to one item in the form
Proposed resolution
- Wait for #3517868: Add e2e tests for multi-value textfield widget in page data form (or base a new branch atop of it)
- Add test coverage by adding this to the end of widget-multivalue.cy.js
cy.reload(); confirmTextInputs([ 'Marshmallow Coast', 'The Olivia Tremor Control', 'The Music Tapes', 'Neutral Milk Hotel', ]); - Load form-state from auto-save store in EntityFormController as follows:
- Look for an autosave entry by calling AutoSaveManager::get($entity)
- If one exists, get the form_build_id from $autosave->data['entity_form_fields']['form_build_id'] and set this and 'form_id' in the form state using $form_state->setUserInput. Form ID can be retrieved with
$form->getFormId()in that controller.
User interface changes
Issue fork experience_builder-3514900
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:
Comments
Comment #2
wim leersAFAICT this issue queue component is a more precise match?
Comment #3
larowlanThis is most obvious after #3517868: Add e2e tests for multi-value textfield widget in page data form because if you have added multiple items via ajax, they're missing if you reload the page
Comment #4
larowlanComment #5
larowlanPostponed on #3517868: Add e2e tests for multi-value textfield widget in page data form
Bumping to critical because there is data loss here.
Updated issue summary.
This can be based on top of #3517868: Add e2e tests for multi-value textfield widget in page data form if someone wants to work on it in the meantime.
Comment #6
phenaproximaWill start this tomorrow based on the very clear suggestions in the issue summary. Thanks @larowlan!
Comment #7
larowlanIf you're debugging, this hunk in FormBuilder is where it should pick up the form cache based on the autosave entry.
Comment #9
phenaproximaI'm a little puzzled. End-to-end tests are failing because there are several places where they assert that the form build ID has changed. That, apparently, is now inverted by the changes we're making.
What's the desired approach here -- do we expect the same form build ID to persist (in which case these assertions need to be changed), or do we expect a new build of the form, populated by data from the auto-save manager?
Comment #10
larowlanI think what is happening is the converse of what we're fixing in the issue this is blocked on
IE there's a cached programmed form state, which prevents Ajax rebuilding the form
It felt too easy that this would just work 😄
The changes the other issue make to ensure the form state is programmed even if cached. We will need the controller to ensure the form state is not programmed even if cached
Can pick it up Tues morn my time
Comment #11
larowlan🤦I'm overthinking it
We can't set input on post requests as it ignores the submitted values
So we just need to wrap the new changes in a check for GET method on the request
Hopefully that's the sauce
Comment #12
larowlanShould this be a beta blocker - there's data loss in HEAD with this - steps to reproduce
* add a multi-value field
* add three values and save a draft to auto-save
* reload page and see the second and third values missing
Comment #13
larowlanComment #14
larowlanRebased on top of #3529622: Make auto-save manager only support passing and returning entity objects, remove support for arbitrary data, use deterministic hashing to ensure entries are actually updates as that makes this much simpler, back to postponed until that is in.
Comment #15
tedbow#3529622: Make auto-save manager only support passing and returning entity objects, remove support for arbitrary data, use deterministic hashing to ensure entries are actually updates is in!
Comment #16
larowlanComment #17
larowlanThis is ready for reviews
Comment #18
larowlanThis ended up being really straight forward in the end, much simpler than the previous iterations - because of #3529622: Make auto-save manager only support passing and returning entity objects, remove support for arbitrary data, use deterministic hashing to ensure entries are actually updates
Comment #19
nagwani commentedComment #20
wim leers#18++ — nice!
Merged in upstream now that #3492722: Update XB to require Drupal 11.2 is in, hopefully still green 🤞
Comment #21
wim leersLooks great!
Comment #23
wim leersPer #12, tagging .
Comment #24
neha_bawankar commentedTested changes on branch
0.x, following scenarios :Scenario
Result
Status
xb_test_article_fieldsmodule and add an article nodexb_test_article_fieldsmodule and add an article nodexb_test_article_fieldsmodule and add an article nodexb_test_article_fieldsmodule and add an article nodeThe content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.At step 10 , on publish we get error as :
The submitted value in the Text format element is not allowed.The submitted value in the Text format element is not allowed.xb_test_article_fieldsmodule and add an article nodexb_test_article_fieldsmodule and add an article nodeAt step 7 , on reload all the three items are back
Comment #25
neha_bawankar commentedComment #26
neha_bawankar commentedComment #27
neha_bawankar commented