Calling ajax request to save draft on node delete page, I don't understand what do we save on the node delete (/node/%/delete) page, there won't be any changes, but still it's sending ajax requests to save content. Could you please clarify ?

I have just installed this module 8.x-1.0 through composer and tested manually, it's working only the node edit page, but not on the new node.

Command icon 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

reddyweb created an issue. See original summary.

hchonov’s picture

Calling ajax request to save draft on node delete page, I don't understand what do we save on the node delete (/node/%/delete) page, there won't be any changes, but still it's sending ajax requests to save content. Could you please clarify ?

It is a generic module and and is enabled on every form and the delete form is a regular entity form and therefore autosave is enabled there as well. In order to prevent it running on delete forms you could retrieve the form operation in \Drupal\autosave_form\Form\AutosaveEntityFormHandler::isAutosaveEnabled() through \Drupal\Core\Entity\EntityForm::getOperation() and return FALSE if it is the delete operation or if the form object class extends from \Drupal\Core\Entity\ContentEntityDeleteForm. However I am curious how did you notice this? Did you had any side effects by having autosave on the delete form?

I have just installed this module 8.x-1.0 through composer and tested manually, it's working only the node edit page, but not on the new node.

There is an issue for this in the issue queue - #2924006: Autosave not working on content creation.

reddyweb’s picture

Thanks much for the quick reply.

I didn't notice any side effects, but was keep getting "saving draft" message while am trying to delete the content, so I was just wondering why we're saving on delete. However based on your instructions above, we will customize and will avoid saving content on delete operation because business authors definitely will raise this concern.

hchonov’s picture

Could you submit a patch please?

reddyweb’s picture

Sure thing, I'm working on it, and will share it once it's done.

s_leu made their first commit to this issue’s fork.

s_leu’s picture

Status: Active » Needs review

Created that patch/MR that was a sure thing 2 years ago ;)

dieterholvoet’s picture

We can simplify the current solution:

  • ContentEntityDeleteForm implements EntityFormInterface, so that check is not necessary.
  • $form_object will always be an instance of EntityFormInterface, this is an assumption we can make so we don't need the instanceof check

I'll rebase and commit to the MR.

dieterholvoet’s picture

Title: Saving draft on the node delete page, but Why? » Stop triggering autosave on delete forms
mglaman’s picture

Status: Needs review » Reviewed & tested by the community
hchonov’s picture

Status: Reviewed & tested by the community » Fixed

Merged. Thank you. This will be part of the 1.6 release.

hchonov’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.