Skip to content

Commit

Permalink
Fix List View not updating when switching editor modes (#67379)
Browse files Browse the repository at this point in the history
* Add back the editorTool dependency to getEnabledClientIdsTree

* Add e2e test

* Switch to getEditorMode selector

----

Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent c5b33b8 commit b867a5f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
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();
} );
} );

1 comment on commit b867a5f

@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 b867a5f.
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/12114067955
📝 Reported issues:

Please sign in to comment.