[SOLVED] Code element doesn’t save modifications (use: "CMD/CTRL + R")

Bricks Version: 1.5 beta
Browser: Chrome 90
OS: macOS / Windows / Linux / etc.
URL: localhost

Hey guys,

Today I experienced several times the same issue with the code element. When I made modifications to a JavaScript code, and saved it, it didn’t update on frontend. When I refresh the builder page, the old code is showing up without modifications. I had to copy/paste the code in a new code element in order to apply the modifications. The other fields get correctly updated.

Cheers.

1 Like

Hi,

I confirm, and same issue in page custom code.

(Sometimes refreshing the code editor allows to save afterwards but behaviour seems pretty erratic.)

Yes, have been experiencing this too. First save worked as expected. Second save after changing code did not save correctly… always defaulted back to initial code!

Same here. I just copy the code, delete the element, save the page add the code back again and it’s good.

Wondering if you all have autosave enabled.

Does the problem also happen when autosave is not on?

Yes, I am not using autosave at all …

Just to confirm, is “Disable autosaved” on in your Bricks settings?

@Sridhar Yes, it is here in my install!

Tried with ‘disable autosave’ but the problem remains.

A workaround in the meantime: Press Run Code icon or ⌘ + R and then Save.

1 Like

You have to click the “Run code” icon or use the “CMD/CTRL + R” keyboard shortcut to execute your code changes as mentioned in the Academy: Custom Code – Bricks Academy

This has always been the case since we introduced code execution.

Automatically executing your code after every keystroke or even with a slight debounce/timeout could put a lot of strain on your server. Especially if it’s resource-intensive PHP code.

But we’ll improve the logic to auto-execute the code for you on save and when clicking outside the code editor (blur) in the next release. The click has to happen on the control panel, though. Because if you click on the canvas the element is no longer being edited and won’t re-render in-time.

As a general rule of thumb & best-practice: Press “CMD/CTRL + R” after you’ve finished editing your code

Hey Thomas, the problem is not just that the code is not automatically running. If you make changes to the code, save it and click on another element, and re-enter in the code element, the changes disappeared and the changes aren’t saved.

When the code runs, it is persisted in the builder as well. Which is why the “CMD/CTRL + R” works.

But ya, I’ll throw in a code re-run whenever the mouse is moved and there are code changes that did not “run”. That should cover everything. You’ll see :call_me_hand:

2 Likes

Marking this one solved as non-PHP code (HTML, CSS, JS) runs automatically in the 1.5 RC2, and PHP code is executed as soon as you move your mouse, save, or use the "Run code"keyboard shortcut “CMD / CTRL + R”. The reasons for why this is necessary I explain & showcase in the following video:

2 Likes