Skip to content

Directly Edit in Breakdance with CPTs that have a template doesn't inform users (no modal displayed, No Canvas error) #1329

Description

@craigblainwyoming

Summary

Opening a post/page in Breakdance when that post is rendered by a Breakdance Template (via Template assignment/conditions) fails to show the expected "This post can't be edited directly" redirect modal. Instead, the builder loads with no Canvas ("No canvas element" console error), unstyled/unrendered content, no Structure pane, and the Add (+) button in the Components pane spins indefinitely with no result.

This is not limited to a specific post type, hierarchical CPTs, or parent/child post relationships. It reproduces across all public post types on the affected sites.

Steps to reproduce

  1. Create a CPT
  2. Assign a Single "post_type" template
  3. Enable direct editing in Breakdance > Settings > Post Type for the created post type
  4. Create a single CPT and publish
  5. Edit in Breakdance
  6. Instead of seeing the modal like you would in Posts eg. "This Post can't be edited directly.", you are presented with unstyled content, Add pane spins indefinitely and No canvas element error in the console.

Expected behaviour

When editing a post directly in Breakdance where that post is currently rendered via an assigned/matched Breakdance Template (and the template does not contain a Template Content Area element), Breakdance should present the "This post can't be edited directly" modal with the option to Edit Template or Go back.

Actual behaviour

The modal does not appear. The builder attempts to load the Canvas and fails silently in the UI (browser console shows "No canvas element"). The result is:

  • No Canvas / unstyled content rendered in the builder
  • No Structure pane
  • Add (+) in the Components pane spins indefinitely and never resolves

Environment

WordPress Core 7.0.2
Breakdance 2.8.0, 2.8.1, 3.0 Beta 2 (all affected)
Breakdance <=2.7.2 (confirmed working, not affected)
PHP 8.2
Hosting WP Engine
Tested environments Production, Staging, Development (3 separate WP Engine environments, same result on all three), Tested in breakdance.com/try instawp site, same behaviour.

Steps to reproduce

  1. On a site with one or more Breakdance Templates assigned via Template conditions (post type, taxonomy, or custom condition) to a public post type.
  2. Ensure a given post does not have a Template Content Area element in the applicable Template.
  3. Open that post directly in Breakdance ("Edit with Breakdance" from the post list or block editor).
  4. Observe that the "This post can't be edited directly" modal does not appear.
  5. Observe the builder loads with no Canvas, no Structure pane, and a spinning Add (+) button in Components.
  6. Downgrade Breakdance to 2.7.2 on the same post/environment and repeat step 3. The modal displays correctly and the builder does not attempt to load the Canvas.

Bisection

This was isolated by version downgrade/upgrade on the same site and same post, with no other changes. 2.7.2 works correctly. 2.8.0, 2.8.1, and 3.0 Beta 2 all reproduce the issue.

Supporting investigation

Comparing the 2.7.2 and 2.8.1 plugin source, doesRuleApply() in themeless/request.php now passes an additional 'templating' context argument to condition callbacks that did not exist in 2.7.2:

// 2.8.1
call_user_func(
    $maybeCondition['callback'],
    $rule['operand'] ?? '',
    getCleanValueFromRuleValue($rule['value'] ?? null),
    $rule['ruleDynamic'] ?? '',
    'templating'
);

Correspondingly, themeless/rules/conditions/singular.php was updated to consume this new $context argument and call is_singular() conditionally when $context === 'templating'. This appears to be new template-evaluation-context handling introduced in 2.8.0 that behaves differently to 2.7.2 when a Template's assignment conditions are evaluated for the post currently open in the builder. I haven't been able to trace this all the way through to the specific function responsible for the modal/editability check in the builder's document-load request, so I can't say with certainty this is the root cause, but it is a confirmed, version-gated behavioural change in the area of the code this bug sits in, and is offered here as a starting point for investigation.

Impact

Editors on affected post types cannot open Breakdance on any post currently governed by a Template, since the intended safety redirect (the modal) doesn't fire and they're instead dropped into a non-functional builder state.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions