Skip to content

Commit 3bf6493

Browse files
committed
Editor: Merge Editor bug fixes ahead of 6.5 RC4.
This merges several high priority bug fixes for the editor ahead of WordPress 6.5: - WordPress/gutenberg#60180 - WordPress/gutenberg#60093 - WordPress/gutenberg#60071 - WordPress/gutenberg#60130 - WordPress/gutenberg#59959 - WordPress/gutenberg#60167 Props youknowriad, annezazu, mcsf, jsnajdr, mmaattiiaass, get_dave, scruffian, mikachan, grantmkin, andraganescu, scruffian, antosguillamot, fabiankaegy, huzaifaalmesbah, krupajnanda, colorful-tones, liviopv, mamaduka, kim88, poena, peterwilsoncc, wildworks, swissspidy, desrosj, jorbin. Fixes #60315. Built from https://develop.svn.wordpress.org/trunk@57888 git-svn-id: http://core.svn.wordpress.org/trunk@57389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 3e244ae commit 3bf6493

File tree

10 files changed

+86
-21
lines changed

10 files changed

+86
-21
lines changed

wp-includes/assets/script-loader-packages.min.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

wp-includes/assets/script-loader-packages.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

wp-includes/blocks/navigation.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,14 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
14721472
return $post;
14731473
}
14741474

1475+
/**
1476+
* Skip meta generation when consumers intentionally update specific Navigation fields
1477+
* and omit the content update.
1478+
*/
1479+
if ( ! isset( $post->post_content ) ) {
1480+
return $post;
1481+
}
1482+
14751483
/*
14761484
* We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into
14771485
* all anchor blocks. For the root level, we create a mock Navigation and extract them from there.

wp-includes/blocks/navigation/view.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,20 @@ const {
7474
} = (0,interactivity_namespaceObject.getContext)();
7575
if (type === 'submenu' &&
7676
// Only open on hover if the overlay is closed.
77-
Object.values(overlayOpenedBy || {}).filter(Boolean).length === 0) actions.openMenu('hover');
77+
Object.values(overlayOpenedBy || {}).filter(Boolean).length === 0) {
78+
actions.openMenu('hover');
79+
}
7880
},
7981
closeMenuOnHover() {
80-
actions.closeMenu('hover');
82+
const {
83+
type,
84+
overlayOpenedBy
85+
} = (0,interactivity_namespaceObject.getContext)();
86+
if (type === 'submenu' &&
87+
// Only close on hover if the overlay is closed.
88+
Object.values(overlayOpenedBy || {}).filter(Boolean).length === 0) {
89+
actions.closeMenu('hover');
90+
}
8191
},
8292
openMenuOnClick() {
8393
const ctx = (0,interactivity_namespaceObject.getContext)();

wp-includes/blocks/navigation/view.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-includes/js/dist/block-editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49267,7 +49267,7 @@ const BlockSwitcher = ({
4926749267
invalidBlocks: true
4926849268
};
4926949269
}
49270-
const rootClientId = getBlockRootClientId(clientIds);
49270+
const rootClientId = getBlockRootClientId(Array.isArray(clientIds) ? clientIds[0] : clientIds);
4927149271
const [{
4927249272
name: firstBlockName
4927349273
}] = _blocks;

wp-includes/js/dist/block-editor.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-includes/js/dist/edit-site.js

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26792,8 +26792,26 @@ function makeFontFacesFormData(font) {
2679226792
}
2679326793
}
2679426794
async function batchInstallFontFaces(fontFamilyId, fontFacesData) {
26795-
const promises = fontFacesData.map(faceData => fetchInstallFontFace(fontFamilyId, faceData));
26796-
const responses = await Promise.allSettled(promises);
26795+
const responses = [];
26796+
26797+
/*
26798+
* Uses the same response format as Promise.allSettled, but executes requests in sequence to work
26799+
* around a race condition that can cause an error when the fonts directory doesn't exist yet.
26800+
*/
26801+
for (const faceData of fontFacesData) {
26802+
try {
26803+
const response = await fetchInstallFontFace(fontFamilyId, faceData);
26804+
responses.push({
26805+
status: 'fulfilled',
26806+
value: response
26807+
});
26808+
} catch (error) {
26809+
responses.push({
26810+
status: 'rejected',
26811+
reason: error
26812+
});
26813+
}
26814+
}
2679726815
const results = {
2679826816
errors: [],
2679926817
successes: []
@@ -27021,12 +27039,23 @@ function FontLibraryProvider({
2702127039
// Library Fonts
2702227040
const [modalTabOpen, setModalTabOpen] = (0,external_wp_element_namespaceObject.useState)(false);
2702327041
const [libraryFontSelected, setLibraryFontSelected] = (0,external_wp_element_namespaceObject.useState)(null);
27024-
const baseThemeFonts = baseFontFamilies?.theme ? baseFontFamilies.theme.map(f => setUIValuesNeeded(f, {
27025-
source: 'theme'
27026-
})).sort((a, b) => a.name.localeCompare(b.name)) : [];
27042+
27043+
// Themes Fonts are the fonts defined in the global styles (database persisted theme.json data).
2702727044
const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map(f => setUIValuesNeeded(f, {
2702827045
source: 'theme'
2702927046
})).sort((a, b) => a.name.localeCompare(b.name)) : [];
27047+
const themeFontsSlugs = new Set(themeFonts.map(f => f.slug));
27048+
27049+
/*
27050+
* Base Theme Fonts are the fonts defined in the theme.json *file*.
27051+
*
27052+
* Uses the fonts from global styles + the ones from the theme.json file that hasn't repeated slugs.
27053+
* Avoids incosistencies with the fonts listed in the font library modal as base (unactivated).
27054+
* These inconsistencies can happen when the active theme fonts in global styles aren't defined in theme.json file as when a theme style variation is applied.
27055+
*/
27056+
const baseThemeFonts = baseFontFamilies?.theme ? themeFonts.concat(baseFontFamilies.theme.filter(f => !themeFontsSlugs.has(f.slug)).map(f => setUIValuesNeeded(f, {
27057+
source: 'theme'
27058+
})).sort((a, b) => a.name.localeCompare(b.name))) : [];
2703027059
const customFonts = fontFamilies?.custom ? fontFamilies.custom.map(f => setUIValuesNeeded(f, {
2703127060
source: 'custom'
2703227061
})).sort((a, b) => a.name.localeCompare(b.name)) : [];
@@ -27046,7 +27075,7 @@ function FontLibraryProvider({
2704627075
setLibraryFontSelected(null);
2704727076
return;
2704827077
}
27049-
const fonts = font.source === 'theme' ? baseThemeFonts : baseCustomFonts;
27078+
const fonts = font.source === 'theme' ? themeFonts : baseCustomFonts;
2705027079

2705127080
// Tries to find the font in the installed fonts
2705227081
const fontSelected = fonts.find(f => f.slug === font.slug);
@@ -27127,8 +27156,10 @@ function FontLibraryProvider({
2712727156
// Use the sucessfully installed font faces
2712827157
// As well as any font faces that were already installed (those will be activated)
2712927158
if (sucessfullyInstalledFontFaces?.length > 0 || alreadyInstalledFontFaces?.length > 0) {
27130-
fontFamilyToInstall.fontFace = [...sucessfullyInstalledFontFaces, ...alreadyInstalledFontFaces];
27131-
fontFamiliesToActivate.push(fontFamilyToInstall);
27159+
// Use font data from REST API not from client to ensure
27160+
// correct font information is used.
27161+
installedFontFamily.fontFace = [...sucessfullyInstalledFontFaces];
27162+
fontFamiliesToActivate.push(installedFontFamily);
2713227163
}
2713327164

2713427165
// If it's a system font but was installed successfully, activate it.
@@ -27200,14 +27231,30 @@ function FontLibraryProvider({
2720027231
}
2720127232
};
2720227233
const activateCustomFontFamilies = fontsToAdd => {
27203-
// Merge the existing custom fonts with the new fonts.
27234+
// Removes the id from the families and faces to avoid saving that to global styles post content.
27235+
const fontsToActivate = fontsToAdd.map(({
27236+
id: _familyDbId,
27237+
fontFace,
27238+
...font
27239+
}) => ({
27240+
...font,
27241+
...(fontFace && fontFace.length > 0 ? {
27242+
fontFace: fontFace.map(({
27243+
id: _faceDbId,
27244+
...face
27245+
}) => face)
27246+
} : {})
27247+
}));
27248+
2720427249
// Activate the fonts by set the new custom fonts array.
2720527250
setFontFamilies({
2720627251
...fontFamilies,
27207-
custom: mergeFontFamilies(fontFamilies?.custom, fontsToAdd)
27252+
// Merge the existing custom fonts with the new fonts.
27253+
custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate)
2720827254
});
27255+
2720927256
// Add custom fonts to the browser.
27210-
fontsToAdd.forEach(font => {
27257+
fontsToActivate.forEach(font => {
2721127258
if (font.fontFace) {
2721227259
font.fontFace.forEach(face => {
2721327260
// Load font faces just in the iframe because they already are in the document.

wp-includes/js/dist/edit-site.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.6-alpha-57887';
19+
$wp_version = '6.6-alpha-57888';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)