• Firstly, great work on the plugin. I can create blocks within accordions, which is great.

    I have an accordion block with 6 accordion items in it.

    In Gutenberg editor, when I click the blue “Add Accordion Item” button, the page jumps up to the beginning of the Accordion block. Then I have to scroll all the way back down to the blue button and when I click it again, it works ok.

    Also, when I try to remove an accordion item, the “-” (minus) button does not work. I get an error in console

    react-dom.min.js?ver=16.9.0:15 Uncaught TypeError: Cannot read property 'innerBlocks' of undefined

    Using the latest version of the plugin and WordPress.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Ben Ritner – Kadence WP

    (@britner)

    Thanks for posting, I see the issue, I’ll have a bug fix out Monday morning 🙂

    Ben

    Thread Starter gaillimh

    (@gaillimh)

    Hi Ben,

    I have updated to the latest version and while I can now delete accordion items without the js error, I am still getting a page jump bug.

    It’s doing this on three different WordPress 5.4 installs. I installed the plugin on a WordPress 5.3.2 install and I couldn’t reproduce the bug, but as soon as I updated to WordPress 5.4 the bug was present. I tried disabling all other plugins and Chrome extensions to no avail.

    I cannot reproduce the bug in your demo. Is it running on WP 5.4 yet?

    Here’s how to reproduce the bug.

    1. Add Accordion block
    2. In the SELECT INITIAL STYLE, click a style. (Sometimes page jumps down and no style is selected. You have to select style again.)
    3. Two accordion items are created.
    4. Click “Add Accordion item” button, a new accordion item is created
    5. Click “Add Accordion item” button again, page jumps to top, no new accordion item created
    6. Click “-” button to remove accordion item, item removed
    7. Click “-” button again, page jumps to top of block and no accordion removed

    I can give you logins to my WP if you want to see the issue for yourself.

    Thanks.

    Plugin Contributor Ben Ritner – Kadence WP

    (@britner)

    Hey,
    Thanks for your follow up, I should have clarified the latest versions of Gutenberg have been changing the way focus works, and what you are seeing is that something (like a button) can’t be clicked until the block is selected. When you create an accordion the inner pane becomes the selected block. To create another accordion you have to reselect the parent accordion block (this is what is happening when you click on the button, the button isn’t being pressed instead you are selecting the parent block.

    When you select a block it’s supposed to “come into view” and that is why it’s jumping to the top of the accordion, that parent block is selected so it’s bringing the toolbar into view.

    Similarly, when you remove an item the focus leaves the parent accordion and selects the last inner pane. So again when you click – button it’s actually selecting the block, not clicking a button.

    I don’t have control over focus to change this, And there is merit to the focus switching to the newly created block.

    I don’t have control over the way Gutenberg is not allowing inner actions until the block is selected. That is written into core.

    So at the moment to make this “bug” go way I would have to hide the add pane and remove pane buttons when the parent block is not the selected block. That feels like it could create more confusion.

    So, for the time being, I’m trying to follow along with the Gutenberg development to see if they will allow for some overriding code to take effect in cases like this.

    Otherwise, I’m going to have to get really creative with code.

    When I meant I would have the fix out Monday I was talking about the inability to remove the block.

    I hope that clarifies and explains if you have suggestions I would love to hear it!

    Ben

    Thread Starter gaillimh

    (@gaillimh)

    Hi Ben,

    Thanks for the explanation. I can see now why it is behaving like that.

    It’s going to be a problem trying to train users on this quirk. It wouldn’t make any sense to someone not familiar with the focus behaviour.

    Do you think this is something that would be fixed in the next 2 months? That’s when I would be training users on it.

    In the meantime, could you recommend a jQuery hack that I could try and put together? For example, detect the .click() event on the Add Accordion item button and then tell jQuery to .click() it again and then use .scrollTop() to scroll to that block. I could probably try coding something like that.

    Also, is there a way to skip the SELECT INITIAL STYLE step, which suffers the same focus quirk?

    Plugin Contributor Ben Ritner – Kadence WP

    (@britner)

    Do you think this is something that would be fixed in the next 2 months? That’s when I would be training users on it.

    Not something I can know for sure since it’s based in WordPress core. (you can see the change made from 5.3 to 5.4. I would hope so, but a “fix” might mean removing the buttons all together and placing them in the sidebar. In which case the training would be the same, the user is going to have to click on the accordion block first then click add block. The “fix” in that case would mean they won’t see where to add an pane if the accordion block is not selected.

    I don’t believe a Click event like that would work because it’s being overridden by core. I suggest instead of that kind of hack you are better off hidding the buttons until the accordion is selected, which you could do with css.

    .block-editor-block-list__block.has-selected-ui.is-selected > .wp-block-kadence-accordion > .kt-accordion-add-selecter {
        display:flex;
        
    }
    .block-editor-block-list__block > .wp-block-kadence-accordion > .kt-accordion-add-selecter {
        display:none;
        
    }

    You can remove the intial select by going into the kadence controls (top right) and clicking on the block defaults, then editing the accordion block defaults. Uncheck “Show Presets”

    Ben

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Accordion buggy’ is closed to new replies.