mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Backport min-height block support feature #3940
Closed
andrewserong
wants to merge
13
commits into
WordPress:trunk
from
andrewserong:add/backport-min-height-block-support-feature
Closed
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a668ff3
Backport min-height block support feature
andrewserong c2bb6cd
Fix failing tests
andrewserong c3be880
Fix linting issue
andrewserong df4d498
Add missing line
andrewserong e79718f
Add full stop to comment
andrewserong 6b1b594
Simplify tests
andrewserong 19fa05e
Fix linting issue
andrewserong 432be91
Empty commit to rerun tests
andrewserong 69e218f
Update data provider docblock.
andrewserong adb55ca
Renames test file for coding standard
hellofromtonya cf79639
Rename test class to coding standards
hellofromtonya 811495e
Minor formatting in tests
hellofromtonya 12cebb4
Capitalize 1st letter of function name
hellofromtonya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
/** | ||
* @group block-supports | ||
* | ||
* @covers ::wp_apply_dimensions_support | ||
*/ | ||
class Tests_Block_Supports_wpApplyDimensionsSupport extends WP_UnitTestCase { | ||
/** | ||
* @var string|null | ||
*/ | ||
private $test_block_name; | ||
|
||
public function set_up() { | ||
parent::set_up(); | ||
$this->test_block_name = null; | ||
} | ||
|
||
public function tear_down() { | ||
unregister_block_type( $this->test_block_name ); | ||
$this->test_block_name = null; | ||
parent::tear_down(); | ||
} | ||
|
||
/** | ||
* Tests that minimum height block support works as expected. | ||
* | ||
* @ticket 57582 | ||
* | ||
* @covers ::wp_apply_dimensions_support | ||
* | ||
* @dataProvider data_minimum_height_block_support | ||
* | ||
* @param string $block_name The test block name to register. | ||
* @param mixed $dimensions The dimensions block support settings. | ||
* @param mixed $expected The expected results. | ||
*/ | ||
public function test_minimum_height_block_support( $block_name, $dimensions, $expected ) { | ||
$this->test_block_name = $block_name; | ||
register_block_type( | ||
$this->test_block_name, | ||
array( | ||
'api_version' => 2, | ||
'attributes' => array( | ||
'style' => array( | ||
'type' => 'object', | ||
), | ||
), | ||
'supports' => array( | ||
'dimensions' => $dimensions, | ||
), | ||
) | ||
); | ||
$registry = WP_Block_Type_Registry::get_instance(); | ||
$block_type = $registry->get_registered( $this->test_block_name ); | ||
$block_attrs = array( | ||
'style' => array( | ||
'dimensions' => array( | ||
'minHeight' => '50vh', | ||
), | ||
), | ||
); | ||
|
||
$actual = wp_apply_dimensions_support( $block_type, $block_attrs ); | ||
|
||
$this->assertSame( $expected, $actual ); | ||
} | ||
|
||
/** | ||
* Data provider. | ||
* | ||
* @return array | ||
*/ | ||
public function data_minimum_height_block_support() { | ||
return array( | ||
'style is applied' => array( | ||
'block_name' => 'test/dimensions-block-supports', | ||
'dimensions' => array( | ||
'minHeight' => true, | ||
), | ||
'expected' => array( | ||
'style' => 'min-height:50vh;', | ||
), | ||
), | ||
'style output is skipped when serialization is skipped' => array( | ||
'block_name' => 'test/dimensions-with-skipped-serialization-block-supports', | ||
'dimensions' => array( | ||
'minHeight' => true, | ||
'__experimentalSkipSerialization' => true, | ||
), | ||
'expected' => array(), | ||
), | ||
'style output is skipped when individual feature serialization is skipped' => array( | ||
'block_name' => 'test/min-height-with-individual-skipped-serialization-block-supports', | ||
'dimensions' => array( | ||
'minHeight' => true, | ||
'__experimentalSkipSerialization' => array( 'minHeight' ), | ||
), | ||
'expected' => array(), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Results from a wp.org search:
__experimentalDimensions
https://wpdirectory.net/search/01GR1JTT957N4BM1FAZAHPCQ1C__experimentalDimensions
https://wpdirectory.net/search/01GR1JX1E9HM3BQQQ0GJ457B68So I'm wondering:
'__experimentalDimensions'
previously exposed and used?'__experimentalDimensions'
to upgrade blocks using this setting?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to mitigate:
||
.'dimensions'
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for raising this one @hellofromtonya — this is a pretty interesting case for stabilisation in that the support technically existed prior to this PR (with the name
__experimentalDimensions
) however it was a no-op, in that it didn't actually expose any controls or styles. So even if a plugin had opted in to using it (which is pretty unlikely), there would have been no behaviour from it. Becausemin-height
is a new feature, and the dimensions controls were never exposed or promoted anywhere, I don't think we need to add any handling to deal with the former__experimentalDimensions
name — it appears it was mostly there as a placeholder in code for future features.What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it was a no-op, I think we're good to leave it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @andrewserong and @ntsekouras for the explanation.
tl;dr
No BC concern.
Let me summarize the reasoning:
__experimentalDimensions
setting existed before 6.2.I agree then. It's not a BC concern to remove it. Thank you!