WAIT: Editor breaks when using the "bricks/frontend/render_data" filter

Browser: Chrome 133
OS: macOS

This is a regression from Bricks 1.11 (where it still worked). When using the "bricks/frontend/render_data" filter, the Bricks editor breaks and a JS error appears:

Steps to reproduce:

  • Create a plugin or insert this code into your theme file:
<?php
/*
* Plugin Name: Bricks Filter Bug
*/

add_filter("bricks/frontend/render_data", function ($content, $post_context, $area) {
    if ($area !== "content") { return $content; }
    // $content .= '<div id="test1">test1</div><div id="test2">test2</div>'; // This works
    $content .= '<div id="test1">test1</div>inbetween<div id="test2">test2</div>'; // This doesn't work
    return $content;
}, 10, 3);
  • Open the Bricks editor.

Expected behavior:
Everything functions normally.

Actual behavior:
Elements that are on the right in the tree view aren’t displayed any more in the preview.
In the JS console, the above error appears.

Notes:
When you uncomment the first line with "$content .=" in the code and comment the second one, everything works again. It seems that having text between HTML tags breaks the editor! It’s the same behavior if you add HTML comments.

Hello @johannesglaser ,

I can’t reproduce this issue. Can you try by updating to latest Bricks version (1.12.3)?

In my tests, it correctly appends data on the frontend, but keeps the backend (editor) intact.

Best regards,
Matej

Thanks for the quick response! I now got to investigate the issue and it’s more complex than I thought initially.

These are the additional conditions for the bug that I didn’t notice initially:

  • The code has to be in a plugin (the theme file won’t break it)
  • There has to be a template applied that outputs the Bricks post content

I’ve managed to reproduce the issue on a clean WP instance (with only WP and an activated Bricks theme installed). You can view it here: https://demo.pschwind.de/bricksbug/bricks-filter-bug.mp4

Here is the plugin ZIP file I used in the demo: https://demo.pschwind.de/bricksbug/bricks-filter-bug.php.zip

Thanks again!

Hi @johannesglaser,
the video you linked is only 10s long, and it’s not showing how you reproduced the issue. Can you updated the video showin that?

Because now I still can’t replicate it, so video would be very helpful :slight_smile:

Thank you.
Matej

1 Like

Hi! Thanks for the quick response, as always :slight_smile:

I noticed that opening the video in Firefox shows it only as 10s long for some reason. It works when I open it in Chrome. Could you try that please? Otherwise, maybe download it. If that doesn’t work, I’m also happy to re-upload it somewhere else.

Cheers

@Matej I’ve re-encoded the video so you can view it in Firefox as well now: https://demo.pschwind.de/bricksbug/bricks-filter-bug-reencoded.mp4

Any ideas about how this can happen?

hey @johannesglaser,

I’m so sorry for not responding at that time! I had the message already partly written (I saw it in draft), and I guess I got distracted at that time and I forgot to answer.

Anyway, I was able to replicate the issue on 1.12.3, but not on the latest internal version. This might suggest that the issue was fixed.

I think it’s best that you wait for next Bricks release (2.0 alpha), and check then. If it’s fixed, the all good, and if it’s not, then I was not testing correctly and we will try to replicate it again at that time.

Does it sound ok?
Matej

Thanks! That sound great :tada: Looking forward to it.

1 Like