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

Fix List View not updating when switching editor modes #67379

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ function getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {
*
* @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
*/
export const getEnabledClientIdsTree = createSelector(
getEnabledClientIdsTreeUnmemoized,
( state ) => [
export const getEnabledClientIdsTree = createRegistrySelector( ( select ) =>
createSelector( getEnabledClientIdsTreeUnmemoized, ( state ) => [
state.blocks.order,
state.derivedBlockEditingModes,
state.derivedNavModeBlockEditingModes,
state.blockEditingModes,
state.settings.templateLock,
state.blockListSettings,
]
select( STORE_NAME ).__unstableGetEditorMode( state ),
] )
);

/**
Expand Down
55 changes: 55 additions & 0 deletions test/e2e/specs/editor/various/write-design-mode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,59 @@ test.describe( 'Write/Design mode', () => {
editorSettings.getByRole( 'button', { name: 'Content' } )
).toBeVisible();
} );

test( 'hides the blocks that cannot be interacted with in List View', async ( {
editor,
page,
pageUtils,
} ) => {
await editor.setContent( '' );

// Insert a section with a nested block and an editable block.
await editor.insertBlock( {
name: 'core/group',
attributes: {},
innerBlocks: [
{
name: 'core/group',
attributes: {
metadata: {
name: 'Non-content block',
},
},
innerBlocks: [
{
name: 'core/paragraph',
attributes: {
content: 'Something',
},
},
],
},
],
} );

// Select the inner paragraph block so that List View is expanded.
await editor.canvas
.getByRole( 'document', {
name: 'Block: Paragraph',
} )
.click();

// Open List View.
await pageUtils.pressKeys( 'access+o' );
const listView = page.getByRole( 'treegrid', {
name: 'Block navigation structure',
} );
const nonContentBlock = listView.getByRole( 'link', {
name: 'Non-content block',
} );

await expect( nonContentBlock ).toBeVisible();

// Switch to write mode.
await editor.switchEditorTool( 'Write' );

await expect( nonContentBlock ).toBeHidden();
} );
} );
Loading