JavaScript for WordPress Forums Gutenberg Development Duplicate Inspector Controls

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #40187
    ibenic
    Participant

    I am trying to create some inspector controls when selecting a post (custom block) but everytime I create another block, the custom controls start adding up.

    The block.js code is here:

    View this gist on GitHub

    If I have 2 of my custom blocks, I’ll have 2 selects for Posts (each select is related to each block -> working) but somehow all the controls are being displayed on every block setting of my type.

    I’ve used https://github.com/ahmadawais/create-guten-block for initial setup.

    Image of duplicate controls: https://imgur.com/e43p5RU

    #40204
    Zac Gordon
    Keymaster

    I am less familiar with that Boilerplate but I have seen this error before. May have to do with using a unique key for inspector controls.

    Does the same thing happen when you use the inspector control examples from this course example files?

    #40209
    ibenic
    Participant

    Hi Zac, thank you for such a quick reply.

    Your examples are working fine. I’ve figured it out. Since I am using a Component here and not a regular function, I did not have access to focus. I had to use this.props.focus to access it.


    View this gist on GitHub

    Works with that 😉

    #40217
    Zac Gordon
    Keymaster

    Oh nice! Great catch 🙂

    Thanks for sharing!!!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.