Issues on plugin ctx.saveCurrentItem(false)

Hi,

We are developing an autosave plugin for the editors. We are calling save the item after few key press.
We are using the method: ctx.saveCurrentItem(false)

The issue is if the item is very new(no existing version), then after the call of ctx.saveCurrentItem(false) the cursor is not on the filed that the editor was typing. So the editor again needs to focus on the field by clicking. This issue does not occur if the item is saved once.

Also while the call of ctx.saveCurrentItem(false) is running, if the editor keeps typing, then the newly typed letters(last 2 or 3) are removed after the call of ctx.saveCurrentItem(false) completed. I guess that is because of reloading/resetting fields on the save.

Do you have any suggestion on these issues?

Thanks,
Jyotirmoy Biswas

Hello @jyoti

I’m not sure i understood how to reproduce this issue, could you send a screen recording of the problem so we can take a closer look at it?

Thanks!

Hi,

On this video link: https://watch.screencastify.com/v/uJqnbg6pSFpx0UtjtAit,
please notice the function ctx.saveCurrentItem(false) is called from the plugin after some key type. After the call of ctx.saveCurrentItem(false) the screen automatically scrolled up and the typed filed(title) is focus out. This case is for brand new item and on first save through ctx.saveCurrentItem(false).

On this video link: https://watch.screencastify.com/v/rmIrR4R2UhKr1IxFwJSY
please notice, after some key type the function ctx.saveCurrentItem(false) is called and I still keep typing(in my case on the video ‘test a b c d e f g h i j k l m n o pppp’). The function was called at the time I start typing first “p”. Then though I was still typing another three “ppp”, those (last three ppp) are removed on the call of ctx.saveCurrentItem(false).

Thanks,
Jyotirmoy Biswas

Hello once again @jyoti

I’m sorry to ask you one more thing, but could you send the git repo of your plugin to support@datocms.com so we can take a closer look at the code, and see the issue directly?
I’ve tried doing a similar setup on a random plugin and couldn’t get the same problem, maybe with your code we can narrow down the issue more precisely :slight_smile:

Thank you once again!

Hi,

I have shared the git repo on “support@datocms.com” with the subject Git repo on the issue: Issues on plugin ctx.saveCurrentItem(false).

Thanks,
Jyotirmoy Biswas

Hi,

Is there any feedback to share?

I have shared the git repo on “support@datocms.com” with the subject Git repo on the issue: Issues on plugin ctx.saveCurrentItem(false).

Thanks,
Jyotirmoy Biswas

We’re working on it @jyoti!

Hello @jyoti

We released a plugin that should solve the problems you had!

The first problem seemed to stem from a miss-use of the useEffect and useCallback hooks, and has been solved in that plugin release.

As for the second problem, where you try to type the character “p” while the record is saving and the character is lost: this is not a problem with the plugin system or with your code, but a limitation on the dashboard overall, if you manually save and type something during that process, the characters typed during the saving process will always be lost.

Hope this helps! :slight_smile:

Hi,

Thanks for the new plugin.

Thanks again,
Jyotirmoy Biswas