Skip to content
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

More/backports for beta 2 #59208

Merged
merged 22 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3c9d2cd
Font Library: Replace infinite scroll by pagination (#58794)
pbking Feb 13, 2024
d50c836
Revert "Block Hooks: Set ignoredHookedBlocks metada attr upon inserti…
ockham Feb 13, 2024
16f7948
DataViews: Fix patterns, templates and template parts pagination `z-i…
ntsekouras Feb 13, 2024
50244c6
Block Bindings: Fix disable bindings editing when source is undefined…
SantosGuillamot Feb 13, 2024
942cc3e
Patterns: Fix pattern categories on import (#58926)
ntsekouras Feb 13, 2024
0ef370b
Shadows: Don't assume that core provides defaults (#58973)
scruffian Feb 13, 2024
0f3e9fb
Inserter: Don't select the closest block with editing mode set as dis…
Mamaduka Feb 14, 2024
79dffd9
Make the custom CSS validation error message accessible. (#56690)
afercia Feb 14, 2024
a01f6a7
Inserter: Fix title condition for media tab previews (#58993)
Mamaduka Feb 14, 2024
1e70298
DataViews: Add loading/no results message in grid view (#59002)
ntsekouras Feb 14, 2024
4b25a88
Block editor: pass patterns selector as setting (#58661)
ellatrix Feb 14, 2024
00f7e12
Font Libary: Add missing translation functions (#58104)
t-hamano Feb 15, 2024
9b48e86
Background image support: Fix issue with background position if keybo…
andrewserong Feb 15, 2024
e53ba3b
Editor: Do not open list view by default on mobile (#59016)
youknowriad Feb 15, 2024
18c62df
Refactor to use string instead of an object (#59030)
cbravobernal Feb 15, 2024
81115e7
Fix DFM ui toggling bugs (#59061)
draganescu Feb 15, 2024
2958043
Rich text: fix link paste for internal paste (#59063)
ellatrix Feb 15, 2024
974f545
Image: Mark connected controls as 'readyonly' (#59059)
Mamaduka Feb 15, 2024
ea8ea99
Global Styles: fix console error in block preview (#59112)
t-hamano Feb 16, 2024
1236a04
Site Editor: Fix navigation on mobile web (#59014)
youknowriad Feb 15, 2024
2181591
Revert footer in pages list with DataViews (#59151)
ntsekouras Feb 19, 2024
dfe3d0d
Fix build
youknowriad Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix DFM ui toggling bugs (#59061)
* don't open post editor inspector if DFM is on, hide list view toggle in site editor if DFM is on, don't render post editor inspector if DFM is on

* udpdate tests with the new call for dfm pref and add two tests for when dfm is on

Co-authored-by: draganescu <andraganescu@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
  • Loading branch information
4 people committed Feb 20, 2024
commit 81115e74284818f5e1082689b7e1846fee421c4d
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
import { useEffect, useRef } from '@wordpress/element';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { store as editorStore } from '@wordpress/editor';
import { store as preferencesStore } from '@wordpress/preferences';

/**
* Internal dependencies
Expand All @@ -22,19 +23,25 @@ import {
* @param {number} postId The current post id.
*/
export const useBlockSelectionListener = ( postId ) => {
const { hasBlockSelection, isEditorSidebarOpened } = useSelect(
( select ) => ( {
hasBlockSelection:
!! select( blockEditorStore ).getBlockSelectionStart(),
isEditorSidebarOpened: select( STORE_NAME ).isEditorSidebarOpened(),
} ),
[ postId ]
);
const { hasBlockSelection, isEditorSidebarOpened, isDistractionFree } =
useSelect(
( select ) => {
const { get } = select( preferencesStore );
return {
hasBlockSelection:
!! select( blockEditorStore ).getBlockSelectionStart(),
isEditorSidebarOpened:
select( STORE_NAME ).isEditorSidebarOpened(),
isDistractionFree: get( 'core', 'distractionFree' ),
};
},
[ postId ]
);

const { openGeneralSidebar } = useDispatch( STORE_NAME );

useEffect( () => {
if ( ! isEditorSidebarOpened ) {
if ( ! isEditorSidebarOpened || isDistractionFree ) {
return;
}
if ( hasBlockSelection ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ describe( 'listener hook tests', () => {
isViewportMatch: jest.fn(),
},
},
'core/preferences': {
...storeConfig,
selectors: {
get: jest.fn(),
},
},
[ STORE_NAME ]: {
...storeConfig,
actions: {
Expand Down Expand Up @@ -112,6 +118,7 @@ describe( 'listener hook tests', () => {
'getBlockSelectionStart',
true
);
setMockReturnValue( 'core/preferences', 'get', false );

render( <TestedOutput /> );

Expand All @@ -120,19 +127,52 @@ describe( 'listener hook tests', () => {
).toHaveBeenCalledWith( 'edit-post/block' );
} );
it( 'opens document sidebar if block is not selected', () => {
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
setMockReturnValue(
'core/block-editor',
'getBlockSelectionStart',
false
);
setMockReturnValue( 'core/preferences', 'get', false );

render( <TestedOutput /> );

expect(
getSpyedAction( STORE_NAME, 'openGeneralSidebar' )
).toHaveBeenCalledWith( 'edit-post/document' );
} );
it( 'does not open block sidebar if block is selected and distraction free mode is on', () => {
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
setMockReturnValue(
'core/block-editor',
'getBlockSelectionStart',
true
);
setMockReturnValue( 'core/preferences', 'get', true );

render( <TestedOutput /> );

expect(
getSpyedAction( STORE_NAME, 'openGeneralSidebar' )
).toHaveBeenCalledTimes( 0 );
} );
it( 'does not open document sidebar if block is not selected and distraction free is on', () => {
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
setMockReturnValue( STORE_NAME, 'isEditorSidebarOpened', true );
setMockReturnValue(
'core/block-editor',
'getBlockSelectionStart',
false
);
setMockReturnValue( 'core/preferences', 'get', true );

render( <TestedOutput /> );

expect(
getSpyedAction( STORE_NAME, 'openGeneralSidebar' )
).toHaveBeenCalledTimes( 0 );
} );
} );

describe( 'useUpdatePostLinkListener', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ function Layout( { initialPost } ) {
<PostSyncStatusModal />
<StartPageOptions />
<PluginArea onError={ onPluginAreaError } />
<SettingsSidebar />
{ ! isDistractionFree && <SettingsSidebar /> }
</>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export default function Editor( { isLoading } ) {
( shouldShowListView && <ListViewSidebar /> ) )
}
sidebar={
! isDistractionFree &&
isEditMode &&
isRightSidebarOpen && (
<>
Expand Down
38 changes: 22 additions & 16 deletions packages/editor/src/components/document-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function DocumentTools( {
const { setIsInserterOpened, setIsListViewOpened } =
useDispatch( editorStore );
const {
isDistractionFree,
isInserterOpened,
isListViewOpen,
listViewShortcut,
Expand All @@ -69,6 +70,7 @@ function DocumentTools( {
listViewToggleRef: getListViewToggleRef(),
hasFixedToolbar: getSettings().hasFixedToolbar,
showIconLabels: get( 'core', 'showIconLabels' ),
isDistractionFree: get( 'core', 'distractionFree' ),
};
}, [] );

Expand Down Expand Up @@ -158,22 +160,26 @@ function DocumentTools( {
variant={ showIconLabels ? 'tertiary' : undefined }
size="compact"
/>
<ToolbarItem
as={ Button }
className="editor-document-tools__document-overview-toggle"
icon={ listView }
disabled={ disableBlockTools }
isPressed={ isListViewOpen }
/* translators: button label text should, if possible, be under 16 characters. */
label={ listViewLabel }
onClick={ toggleListView }
shortcut={ listViewShortcut }
showTooltip={ ! showIconLabels }
variant={ showIconLabels ? 'tertiary' : undefined }
aria-expanded={ isListViewOpen }
ref={ listViewToggleRef }
size="compact"
/>
{ ! isDistractionFree && (
<ToolbarItem
as={ Button }
className="editor-document-tools__document-overview-toggle"
icon={ listView }
disabled={ disableBlockTools }
isPressed={ isListViewOpen }
/* translators: button label text should, if possible, be under 16 characters. */
label={ listViewLabel }
onClick={ toggleListView }
shortcut={ listViewShortcut }
showTooltip={ ! showIconLabels }
variant={
showIconLabels ? 'tertiary' : undefined
}
aria-expanded={ isListViewOpen }
ref={ listViewToggleRef }
size="compact"
/>
) }
</>
) }
{ children }
Expand Down