Skip to content

Commit

Permalink
Merge remote-tracking branch 'elementor/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
arielk committed Aug 16, 2023
2 parents 424042a + 589d84f commit 9afdf8f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bump-channel-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ inputs:
description: 'The postfix that will be added to the package version -rc / -test / empty.'
OVERRIDE_PACKAGE_VERSION:
required: false
default: 'false'
description: 'Should override the PACKAGE_VERSION value with a custom value for the one click release process.'

runs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
strategy:
fail-fast: false
matrix:
wordpress_versions: ['nightly', 'latest', '6.0', '5.9']
wordpress_versions: ['nightly', 'latest', '6.0', '6.1', '6.2']
php_versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
name: PHPUnit - WordPress ${{ matrix.wordpress_versions }} - PHP version ${{ matrix.php_versions }}
env:
Expand Down
51 changes: 34 additions & 17 deletions includes/elements/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,39 @@ protected function get_container_type_control_options( $is_container_grid_active
];
}

private function get_full_width_device_args( $active_breakpoints ) {
$full_width_devices_defaults = [];
$default = [ 'unit' => '%' ];

$full_width_devices_settings = [
'default' => $default,
];

foreach ( $active_breakpoints as $breakpoint_name => $breakpoint ) {
if ( Breakpoints_Manager::BREAKPOINT_KEY_MOBILE === $breakpoint_name ) {
continue; // The mobile width is not inherited from the higher breakpoint width controls.
}

$full_width_devices_defaults[ $breakpoint_name ] = $full_width_devices_settings;
}

$default_placeholder = [
'size' => 100,
'unit' => '%',
];

$full_width_devices_defaults[ Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP ] = [
'placeholder' => $default_placeholder,
];

$full_width_devices_defaults[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE ] = [
'placeholder' => $default_placeholder,
'default' => $default,
];

return $full_width_devices_defaults;
}

/**
* Register the Container's layout controls.
*
Expand Down Expand Up @@ -466,22 +499,6 @@ protected function register_container_layout_controls() {
'separator' => 'none',
];

$full_width_devices_defaults = [];

$full_width_devices_settings = [
'default' => [
'unit' => '%',
],
'placeholder' => [
'size' => 100,
'unit' => '%',
],
];

foreach ( $active_breakpoints as $breakpoint_name => $breakpoint ) {
$full_width_devices_defaults[ $breakpoint_name ] = $full_width_devices_settings;
}

$this->add_responsive_control(
'width',
array_merge( $width_control_settings, [
Expand All @@ -491,7 +508,7 @@ protected function register_container_layout_controls() {
'condition' => [
'content_width' => 'full',
],
'device_args' => $full_width_devices_defaults,
'device_args' => $this->get_full_width_device_args( $active_breakpoints ),
] )
);

Expand Down
10 changes: 9 additions & 1 deletion tests/playwright/sanity/container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -844,19 +844,27 @@ test.describe( 'Container tests @container', () => {
} );
} );

test( 'Test full width container default size units', async ( { page }, testInfo ) => {
test( 'Test full width container default size and units', async ( { page }, testInfo ) => {
const wpAdmin = new WpAdminPage( page, testInfo ),
editor = await wpAdmin.openNewPage();

await editor.addElement( { elType: 'container' }, 'document' );

await page.selectOption( '.elementor-control-content_width >> select', 'full' );
await page.locator( '.elementor-control-width [data-setting="size"]' ).fill( '90' );

let currentWidthUnit = await page.locator( '.e-units-switcher > span' ).first();
let currentWidthUnitValue = await currentWidthUnit.innerHTML();

expect( currentWidthUnitValue ).toBe( '%' );

await editor.changeResponsiveView( 'tablet' );

const tabletWidthPlaceholder = await page.locator( '.elementor-control-width_tablet [data-setting="size"]' ),
tabletWidthValue = await tabletWidthPlaceholder.getAttribute( 'placeholder' );

expect( tabletWidthValue ).toBe( '90' );

await editor.changeResponsiveView( 'mobile' );

currentWidthUnit = await page.locator( '.e-units-switcher > span' ).first();
Expand Down

0 comments on commit 9afdf8f

Please sign in to comment.