Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] [4.x] Hidden block types can still be added via the settings "cog" icon on existing blocks #122

Closed
tomdavies opened this issue Oct 11, 2022 · 6 comments · Fixed by #123

Comments

@tomdavies
Copy link
Contributor

Where Spoon has been configured to hide some Matrix blocks for a field layout, these hidden block types can still be added to the field still be via the settings "cog" icon on existing blocks:

Screenshot 2022-10-11 at 12 21 53

The items in that list of matrix block types have a data-type="<blockHandle>" attribute on them, so it should be fairly easy to find that list and hide the block types that are not enabled for this field layout

Screenshot 2022-10-11 at 12 27 26

LMK if you would accept a PR for this!

@tomdavies tomdavies changed the title [bug]. 4.x: Hidden block types can still be added via the settings "cog" icon on existing blocks [bug] [4.x] Hidden block types can still be added via the settings "cog" icon on existing blocks Oct 11, 2022
@tigerchick
Copy link

tigerchick commented Oct 11, 2022

plus 1 for this.
This recently caused me a little trouble with a client adding blocks they weren't meant to be able to!

@tomdavies
Copy link
Contributor Author

tomdavies commented Oct 11, 2022

Having dug into this some more, there is code that should prevent this, but it never fires.

At the start of FieldManipulator::initSettingsMenu() we have:

Garnish.requestAnimationFrame($.proxy(function()
    {
    // Get the Garnish.MenuBtn object
    var menuBtn = $settingsBtn.data('menubtn') || false;
    
    // If there wasn’t one then fail and try again
    if (!menuBtn)
    {
        this.initSettingsMenu($settingsBtn, spoonedBlockTypes, $matrixField);
        return;
    }
...

The problem is $settingsBtn.data('menubtn') is always false. Guessing this is due to a change to the edit screen JS in Craft 4

@tomdavies
Copy link
Contributor Author

Alright, I figured this out. The settings menu now uses Garnish.DisclosureMenu rather than the MenuBtn it used before. Fix is just a small JS change, PR inbound...

@tomdavies
Copy link
Contributor Author

PRed 😄

CC @tigerchick in case you're in a hurry for a fix

@tigerchick
Copy link

PRed 😄

CC @tigerchick in case you're in a hurry for a fix

Thanks @tomdavies !

@lindseydiloreto
Copy link
Contributor

PR has been merged, and the fix has been released in v4.0.2.

Thanks for all of your recent contributions @tomdavies! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants