Skip to content

Commit

Permalink
Fallback to default max viewport if layout wide size is fluid. (#53551)
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Aug 11, 2023
1 parent 77708cb commit da15d73
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_ty

// Defaults overrides.
$minimum_viewport_width = isset( $fluid_settings['minViewportWidth'] ) ? $fluid_settings['minViewportWidth'] : $default_minimum_viewport_width;
$maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : $default_maximum_viewport_width;
$maximum_viewport_width = isset( $layout_settings['wideSize'] ) && ! empty( gutenberg_get_typography_value_and_unit( $layout_settings['wideSize'] ) ) ? $layout_settings['wideSize'] : $default_maximum_viewport_width;
if ( isset( $fluid_settings['maxViewportWidth'] ) ) {
$maximum_viewport_width = $fluid_settings['maxViewportWidth'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
/**
* Internal dependencies
*/
import { getComputedFluidTypographyValue } from '../font-sizes/fluid-utils';
import {
getComputedFluidTypographyValue,
getTypographyValueAndUnit,
} from '../font-sizes/fluid-utils';

/**
* @typedef {Object} FluidPreset
Expand Down Expand Up @@ -99,11 +102,16 @@ function isFluidTypographyEnabled( typographySettings ) {
export function getFluidTypographyOptionsFromSettings( settings ) {
const typographySettings = settings?.typography;
const layoutSettings = settings?.layout;
return isFluidTypographyEnabled( typographySettings ) &&
const defaultMaxViewportWidth = getTypographyValueAndUnit(
layoutSettings?.wideSize
)
? layoutSettings?.wideSize
: null;
return isFluidTypographyEnabled( typographySettings ) &&
defaultMaxViewportWidth
? {
fluid: {
maxViewportWidth: layoutSettings.wideSize,
maxViewportWidth: defaultMaxViewportWidth,
...typographySettings.fluid,
},
}
Expand Down

1 comment on commit da15d73

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in da15d73.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5828558512
📝 Reported issues:

Please sign in to comment.