Skip to content

Commit f72d1db

Browse files
authored
fix: update the editor breakpoints with wordpress 7.0 changes (#3711)
* fix: update the editor breakpoints with wordpress 7.0 changes * fix: compatibility for pre wp7
1 parent fe8f5c3 commit f72d1db

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

src/compatibility/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import './kadence-theme'
22
import './wp-6-2'
3+
import './wp-pre-7'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
import { addFilter } from '@wordpress/hooks'
5+
6+
/**
7+
* Internal dependencies
8+
*/
9+
import { semverCompare } from '~stackable/util'
10+
import { wpVersion } from 'stackable'
11+
12+
addFilter( 'stackable.block-css.editor-preview-breakpoints', 'stackable/wp-pre-7', breakpoints => {
13+
if ( wpVersion && semverCompare( wpVersion, '<', '7.0' ) ) {
14+
return {
15+
tablet: 781,
16+
mobile: 361,
17+
}
18+
}
19+
20+
return breakpoints
21+
} )

src/components/block-css/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,16 @@ function createCssEdit( selector, rule, value, device = 'desktop', vendorPrefixe
535535
}
536536
css = `\n${ selector } {\n\t${ css }\n}`
537537

538-
// The Block Editor has these fixed breakpoints.
539-
const tabletBreakpoint = 781
540-
const mobileBreakpoint = 361
538+
// Match the Block Editor's fixed preview widths. getMediaQuery subtracts 1,
539+
// so these default values target 781px tablet and 479px mobile in WordPress 7.0.
540+
// https://github.com/WordPress/gutenberg/pull/74339
541+
const { tablet: tabletBreakpoint, mobile: mobileBreakpoint } = applyFilters(
542+
'stackable.block-css.editor-preview-breakpoints',
543+
{
544+
tablet: 782,
545+
mobile: 480,
546+
}
547+
)
541548

542549
const mediaQuery = getMediaQuery( device, tabletBreakpoint, mobileBreakpoint )
543550
if ( mediaQuery ) {

0 commit comments

Comments
 (0)