Skip to content

Commit 35ddbfb

Browse files
andrewserongtalldanellatrix
authored
List View: Fix home and end key behaviour in very long lists (#62312)
* 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>
1 parent f1016e9 commit 35ddbfb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/block-editor/src/components/list-view/branch.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,14 @@ function ListViewBranch( props ) {
194194
// This prevents the entire tree from being rendered when a branch is
195195
// selected, or a user selects all blocks, while still enabling scroll
196196
// into view behavior when selecting a block or opening the list view.
197+
// The first and last blocks of the list are always rendered, to ensure
198+
// that Home and End keys work as expected.
197199
const showBlock =
198200
isDragged ||
199201
blockInView ||
200-
( isSelected && clientId === selectedClientIds[ 0 ] );
202+
( isSelected && clientId === selectedClientIds[ 0 ] ) ||
203+
index === 0 ||
204+
index === blockCount - 1;
201205
return (
202206
<AsyncModeProvider key={ clientId } value={ ! isSelected }>
203207
{ showBlock && (

test/e2e/specs/editor/various/list-view.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ test.describe( 'List View', () => {
11201120
'Pressing keyboard shortcut should also work when the menu is opened and focused'
11211121
)
11221122
.toMatchObject( [
1123-
{ name: 'core/paragraph', selected: true, focused: false },
1123+
{ name: 'core/paragraph', selected: true, focused: true },
11241124
{ name: 'core/file', selected: false, focused: false },
11251125
] );
11261126
await expect(

0 commit comments

Comments
 (0)