Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The following is a curated list of changes in the Enact limestone module, newest
### Fixed

- `limestone/TabLayout` isomorphic build
- `limestone/VirtualList` long press scroll between multiple VirtualLists

## [1.9.4] - 2026-06-18

Expand Down
20 changes: 0 additions & 20 deletions VirtualList/tests/useEvent-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,6 @@ describe('VirtualList useEvent', () => {
global.Element.prototype.scrollTo = scrollToFn;
});

test('should handle repeat keydown on first VirtualList entry without error', () => {
render(
<VirtualList
clientSize={clientSize}
dataSize={dataSize}
itemRenderer={renderItem}
itemSize={itemSize}
/>
);

const list = screen.getByRole('list');
const item0 = list.children.item(0).children.item(0);

focus(item0);
expect(currentFocusIndex).toBe(0);

keyDownRepeat(40)(item0);
expect(currentFocusIndex).toBe(0);
});

test('should handle repeat keydown when data-index jumps unexpectedly without error', () => {
render(
<VirtualList
Expand Down
16 changes: 2 additions & 14 deletions VirtualList/useEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const useEventKey = (props, instances, context) => {
});

const prevKeyDownIndexRef = useRef(-1);
const hasProcessedKeyDownRef = useRef(false);

// Functions

Expand Down Expand Up @@ -159,22 +158,12 @@ const useEventKey = (props, instances, context) => {
// Detect this by checking if the index jumped unnaturally during key repeat.
const isForwardKey = isPrimaryDirectionVertical ? isDownKey : isRightMovement;
const isBackwardKey = isPrimaryDirectionVertical ? isUpKey : isLeftMovement;
const isOutdatedIndex = repeat && prevKeyDownIndexRef.current !== -1 && (
const isMovingWithinList = nextIndex >= 0;
const isOutdatedIndex = isMovingWithinList && repeat && prevKeyDownIndexRef.current !== -1 && (
(isForwardKey && (prevKeyDownIndexRef.current > index || index > prevKeyDownIndexRef.current + dimensionToExtent)) ||
(isBackwardKey && (prevKeyDownIndexRef.current < index || index < prevKeyDownIndexRef.current - dimensionToExtent))
);

// Block the first repeat event when entering VirtualList from outside with acceleration.
// prevKeyDownIndexRef is -1 only on first entry; a repeat here means key was held before entering.
const isFirstEntryRepeat = repeat && !hasProcessedKeyDownRef.current;

if (isFirstEntryRepeat) {
ev.preventDefault();
ev.stopPropagation();
resetAccelerator();
return;
}

if (isOutdatedIndex) {
ev.preventDefault();
ev.stopPropagation();
Expand Down Expand Up @@ -249,7 +238,6 @@ const useEventKey = (props, instances, context) => {
}

prevKeyDownIndexRef.current = index;
hasProcessedKeyDownRef.current = true;

if (isLeaving) {
handleDirectionKeyDown(ev, 'keyLeave');
Expand Down
Loading