Skip to content

Commit

Permalink
List View: Fix home and end key behaviour in very long lists (#62312)
Browse files Browse the repository at this point in the history
* List View: Fix home and end key behaviour in very long lists

* Update e2e test

Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
  • Loading branch information
4 people committed Jun 18, 2024
1 parent 3c7bf59 commit e5ed9dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/block-editor/src/components/list-view/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,14 @@ function ListViewBranch( props ) {
// This prevents the entire tree from being rendered when a branch is
// selected, or a user selects all blocks, while still enabling scroll
// into view behavior when selecting a block or opening the list view.
// The first and last blocks of the list are always rendered, to ensure
// that Home and End keys work as expected.
const showBlock =
isDragged ||
blockInView ||
( isSelected && clientId === selectedClientIds[ 0 ] );
( isSelected && clientId === selectedClientIds[ 0 ] ) ||
index === 0 ||
index === blockCount - 1;
return (
<AsyncModeProvider key={ clientId } value={ ! isSelected }>
{ showBlock && (
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/list-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ test.describe( 'List View', () => {
'Pressing keyboard shortcut should also work when the menu is opened and focused'
)
.toMatchObject( [
{ name: 'core/paragraph', selected: true, focused: false },
{ name: 'core/paragraph', selected: true, focused: true },
{ name: 'core/file', selected: false, focused: false },
] );
await expect(
Expand Down

0 comments on commit e5ed9dc

Please sign in to comment.