When user edit the form and inactive for few minutes. Then it gives error message from

autosave_form/js/autosave_form.js

   
$('<div></div>').appendTo('body')
   

.html('<div>' + Drupal.t('A server error occurred during autosaving the current page. As a result autosave is disabled. To activate it please revisit the page and continue the editing from the last autosaved state of the current page.') + '</div>')
   
.dialog(dialogOptions);
   

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

shahankitb created an issue. See original summary.

shahankitb’s picture

Title: Error message appeared on inactivity » Error message appears on user inactivity
Issue summary: View changes
shahankitb’s picture

Issue summary: View changes
shahankitb’s picture

shahankitb’s picture

Status: Needs work » Closed (won't fix)
shahankitb’s picture

Issue summary: View changes
shahankitb’s picture

Title: Error message appears on user inactivity » User error message
hchonov’s picture

Status: Closed (won't fix) » Postponed (maintainer needs more info)

Your patch simply removes the message, but autosave is already disabled when the message appears. Currently when the browser client is unable to reach the server or some error occurs during the communication, then autosave will be disabled. Could you please check why does it it happen, that your communication is being interrupted?

shahankitb’s picture

To resolve this issue would probably require changes to the Javascript to reconnect to the server when a connection is broken.

shahankitb’s picture

Title: User error message » Error message shown due to user inactivity

When user edit the form and inactive for few minutes. Then it gives error message from

autosave_form/js/autosave_form.js

   
$('<div></div>').appendTo('body')
   

.html('<div>' + Drupal.t('A server error occurred during autosaving the current page. As a result autosave is disabled. To activate it please revisit the page and continue the editing from the last autosaved state of the current page.') + '</div>')
   
.dialog(dialogOptions);
   

shahankitb’s picture

Issue summary: View changes
hchonov’s picture

As you see the message shows how to resolve the problem :).
I think it might be okay to still show the message, but instead of completely disabling autosave continue trying to reach the server. However from now on the notification in the right down corner should warn about an error during autosave.

What do you think? Do you wanna give it a try?

hchonov’s picture

Status: Postponed (maintainer needs more info) » Active
shubhangi1995’s picture

Hi @hchonov
seems the "pagehide" in line 36 in autosave_form.js is the main reason as its not getting triggered, on page change maybe we can use document hidden ?

  document.addEventListener("visibilitychange", function() {
    if( document.hidden == true && Drupal.autosaveForm.beforeUnloadCalled == false ){
      Drupal.autosaveForm.beforeUnloadCalled = true;
    }
});
shubhangi1995’s picture

Assigned: Unassigned » shubhangi1995
Status: Active » Needs work
shubhangi1995’s picture

StatusFileSize
new699 bytes
shubhangi1995’s picture

Assigned: shubhangi1995 » Unassigned
Status: Needs work » Needs review
hchonov’s picture

@shubhangi1995, isn't the problem that for some reason the request isn't successful and therefore the message is shown?

Maybe a network issue or something in that way?

What if we instead offer a button on the message to try to re-establish the autosave session?

shubhangi1995’s picture

@hchonov sure we could, but would not that bring more complexity soecially for content editors as they might feel it redundant and would like to get it automatica.

hchonov’s picture

Should we then show the message only if there is user interaction and otherwise just keep trying to perform the request?

shubhangi1995’s picture

i think we should test if user is active or not if he is active only then call should go else there should be no call.
Pros: no unnecessary calls + no unwanted warnings.

hchonov’s picture

This would be very good, yes. Actually I've even been thinking at some point to send the requests only if there was change since the last request. I guess that would also be easier to implement as it might just need one onchange event listener on the form input elements and then flag the form as needing autosaving when the next autosave interval occurs.

Something like this eventually:

var form = document.getElementById("form_id");

form.addEventListener("input", function () {
    // Set a needsAutosave flag to TRUE.
});

hchonov credited Dave Reid.

hchonov’s picture

Title: Error message shown due to user inactivity » Trigger autosave only if the form has changed

I've added a new experimental option which will limit the autosave submissions to only when the form has changed. The detection mechanism is based on a modified version of https://www.drupal.org/project/entity_form_monitor, which is why I am crediting the maintainer of that project - Dave Reid.

hchonov’s picture

Status: Needs review » Fixed

With this I consider this issue as resolved. Feel free to re-open if it does not work as expected after you've enabled the new option in the Autosave Settings.

Status: Fixed » Closed (fixed)

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

shubhangi1995’s picture

hchonov thanks for the changes :)