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

AlignmentControlMatrix display doesn't respect the width prop. #34665

Open
ryanwelcher opened this issue Sep 8, 2021 · 2 comments
Open

AlignmentControlMatrix display doesn't respect the width prop. #34665

ryanwelcher opened this issue Sep 8, 2021 · 2 comments
Labels
[Feature] Component System WordPress component system [Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Comments

@ryanwelcher
Copy link
Contributor

Description

While updating the documentation for the AlignmentControlMatrix, I found that no matter what value I passed to the width prop, the display was always the same.

Step-by-step reproduction instructions

  1. Add the code snippet to a plugin
  2. Change the width value to anything other than the default of 92
  3. The widget of the component is unchanged

Screenshots, screen recording, code snippet

I created a simple plugin with the following code to render the control:

import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';
import { useState } from '@wordpress/element';
import { registerPlugin } from '@wordpress/plugins';
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';

const Example = () => {
	const [ alignment, setAlignment ] = useState( 'center center' );
	return (
		<PluginDocumentSettingPanel title="test">
			<AlignmentMatrixControl
				width="2000"
				value={ alignment }
				onChange={ ( newAlignment ) => setAlignment( newAlignment ) }
			/>
		</PluginDocumentSettingPanel>
	);
};

registerPlugin( 'my-plugin', { render: Example } );

As you can see in the screenshot, the value is passed to the markup but the default value ( 92 ) is overriding the styles.
AlignmentMatrixControl

Environment info

  • Wordpress 5.8 using a default theme.

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

@ryanwelcher ryanwelcher added [Package] Components /packages/components [Feature] Component System WordPress component system labels Sep 8, 2021
@ryanwelcher
Copy link
Contributor Author

Discovered while working on #34662

@ryanwelcher ryanwelcher added the [Type] Bug An existing feature does not function as intended label Jan 6, 2022
@ajskelton
Copy link

@ryanwelcher While testing out the AlignmentControlMatrix today I came across this old open issue. However it appears to be fixed now as setting the width attribute does control the width of the component.

Here is a playground with a block using the AlignmentControlMatrix component and the width is set to 248 (the max width of the sidebar when inside a PanelBody). AlignmentMatrixTest Playground

That playground is loading this plugin that has a simple block using the AlignmentMatrixControl: Plugin Block with width attribute set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Component System WordPress component system [Package] Components /packages/components [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants