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

Cannot align inner blocks in flex layout when allowSwitching is set to true #67016

Closed
3 of 6 tasks
metropoliscreative opened this issue Nov 14, 2024 · 3 comments · Fixed by #67022
Closed
3 of 6 tasks
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Type] Bug An existing feature does not function as intended

Comments

@metropoliscreative
Copy link

Description

When a block has layout support and the allowSwitching subproperty is set to true, the vertical alignment setting should be displayed in the block toolbar when the layout is set to flex. The alignment setting is not shown unless allowSwitching is set to false (the default) and flex is the default layout type.

Step-by-step reproduction instructions

Create a block with layout support and allowSwitching set to true

Screenshots, screen recording, code snippet

This is the code that prevents the alignment button from being added to the block toolbar when allowSwitching is set to true:

if ( layoutBlockSupport?.allowSwitching ) {
return null;
}

Environment info

WordPress 6.7, Gutenberg plugin not active

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@metropoliscreative metropoliscreative added the [Type] Bug An existing feature does not function as intended label Nov 14, 2024
@Mayank-Tripathi32
Copy link

@metropoliscreative Could you share a recorded video of the issue? Also, could you clarify the intended behavior here and the reasoning behind it?

Thanks

@metropoliscreative
Copy link
Author

First video shows a sample block with layout support and the default layout type set to flex. The block toolbar contains both justification and alignment controls.

block.json supports:

"supports": {
    "layout": {
        "allowSwitching": false,
        "default": {
            "type": "flex"
        }
    }
}
Screen.Recording.2024-11-14.at.3.42.10.PM.mov

The next video shows the same block with allowSwitching enabled. When the Flex layout is selected for the block there is a justification control but no alignment control.

block.json supports:

"supports": {
    "layout": {
        "allowSwitching": true
    }
}
Screen.Recording.2024-11-14.at.3.41.12.PM.mov

could you clarify the intended behavior here and the reasoning behind it?

I would expect the block to receive alignment control along with justification control when the layout type is set to flex, even if switching the layout type is enabled for the block.

@Mamaduka Mamaduka added Needs Testing Needs further testing to be confirmed. [Feature] Layout Layout block support, its UI controls, and style output. labels Nov 15, 2024
@Infinite-Null
Copy link
Contributor

Hi @metropoliscreative,

Thank you for bringing this up. I’ve looked into it and was able to reproduce the issue as follows:

For the configuration:

"supports": {
    "layout": {
        "allowSwitching": true
    }
},

Here is the resulting behavior (No settings in block toolbar):

Image

For the configuration:

"supports": {
    "layout": {
        "allowSwitching": false,
        "default": {
            "type": "flex"
        }
    }
}

Here is the resulting behavior:

Image

To improve accessibility and provide a better user experience, I believe adding settings for this functionality within the block toolbar would be a great enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Layout Layout block support, its UI controls, and style output. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants