elegantthemes / Divi-Beta

8 stars 0 forks source link

Save event triggers Axios 'get' request #42

Open dtcblyth opened 10 months ago

dtcblyth commented 10 months ago

Related thread: https://discord.com/channels/1041765492907589683/1079860683623116862/threads/1184025566576394240

Problem:

I am working on implementing a custom async request in one of my extensions. Note, I am not using the Divi-5 RestAPI/Fetch implementation. Instead, I am using my own custom Rest Route with an Axios get request.

I have noticed that when saving the page in the Visual Builder using the quick-key (Command-s) it is triggering the page to redraw and therefore also triggering the get request to run. This doesn’t happen when clicking on the Save button in the Visual Builder, only when using the quick-key. Also, it doesn’t seem to occur when using the Divi-5 RestAPI/Fetch implementation.

Is there anyway that I can prevent this redraw from happening, and/or detect the save event and prevent the get request from running?

I have attached a screen recording. It shows me saving the page twice. Once using the quick-key and the second time clicking on the Save button. Notice how when using the quick-key the table (which is fetched with the Axios get request) is re-loaded. But when clicking the Save button it isn’t.

Any help would be appreciated. Thanks!

2023-12-12_2-42-47_PM 2023-12-12_2_45_19_PM gifcask 2024-01-24 2_32_29 PM