• Resolved joined93

    (@joined93)


    I’ve been using Spectra One with Spectra Gutenberg Blocks for a few months without major issues. Since a few days I cannot seem to use the Design Library anymore. I can open it, browse the blocks, but when I try to insert any of them in a standard page, the library closes and the block is not inserted. I am using WP 6.8.1 and the Spectra plugin v2.19.9 (latest).

    I did a fair amount of debugging to figure out the issue, which was made much more difficult by the fact that the code that makes the design library work (main.js, GitHub link) is minified and no unminified version is provided.

    The mentioned script calls the block editor core function insertBlocks to insert the selected block, but this fails because the passed rootClientId is always ''. In insertBlocks there is a canInsertBlockType(block.name, rootClientId) check, which calls getBlockEditingMode(rootClientId), which returns false because the editing mode of the '' client ID is set to disabled by the WP core component DisableNonPageContentBlocks.

    I think the problem is that your code is trying to insert the block at the top level, but when using a FSE enabled theme like Spectra One, the top level contains element outside of the page content (e.g. header, title, footer), so that’s not allowed. This is confirmed by the fact that calling wp.data.dispatch( 'core/block-editor' ).setBlockEditingMode('', 'contentOnly'); in the browser console and then trying to inserting a block from the design library works fine; except that the block is inserted at the top level, not within the page content, which is wrong.

    In your main.js, you are already calling the core function getInsertionPoint, but only to get the index at which to insert the block, discarding the rootClientId that it returns. Using that client id to insert the block would solve the problem, I think (but I am just a dev—not a WP expert).

    I unfortunately don’t have an explanation for how I was able to use the design library just fine in the past. I tried also rolling back to a previous version of the plugin but it didn’t help.

    • This topic was modified 1 year ago by joined93.
    • This topic was modified 1 year ago by joined93.
    • This topic was modified 1 year ago by joined93. Reason: add more details
Viewing 2 replies - 1 through 2 (of 2 total)
  • Mohsin Ghouri

    (@mohsinbsf)

    Hi @joined93,

    Sorry for the inconvenience caused to you.

    I am not able to replicate the issue on my installation. I request you open a support ticket from here:https://wpspectra.com/support/ so that our support dev can check your site configuration and assist you.

    Have a nice day!

    Thread Starter joined93

    (@joined93)

    Hi @mohsinbsf,

    The issue only happens if the full-site editor is used. I’m not sure under what conditions this happens, but when I edit a page (via Pages -> Edit page, not the theme editor), the editor contains not only the page content but also elements outside of it like header and footer. I believe this is what the WordPress team refers to as “template locked” rendering mode. It seems that this rendering mode can be “forced” by opening the preview options in the page editor and enabling “Show template”.

    Please try again to reproduce under these conditions.

    I have no interest in filing a support request through your website, sorry.

    Have a nice day!

    • This reply was modified 1 year ago by joined93.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cannot insert blocks from Design Library’ is closed to new replies.