Skip to content

Commit cc5050e

Browse files
langleydomitech
authored andcommitted
Only highlight/focus the item after scrolling has finished (element-hq#30888)
1 parent 6bf785c commit cc5050e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

playwright/e2e/left-panel/room-list-panel/room-list.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,26 @@ test.describe("Room list", () => {
252252
// Focus should be back on the notification button
253253
await expect(notificationButton).toBeFocused();
254254
});
255+
256+
test("should navigate to the top and then bottom of the room list", async ({ page, app, user }) => {
257+
const roomListView = getRoomList(page);
258+
259+
const topRoom = roomListView.getByRole("option", { name: "Open room room29" });
260+
261+
// open the room
262+
await topRoom.click();
263+
// put focus back on the room list item
264+
await topRoom.click();
265+
await expect(topRoom).toBeFocused();
266+
267+
await page.keyboard.press("End");
268+
const bottomRoom = roomListView.getByRole("option", { name: "Open room room0" });
269+
await expect(bottomRoom).toBeFocused();
270+
271+
await page.keyboard.press("Home");
272+
const topRoomAgain = roomListView.getByRole("option", { name: "Open room room29" });
273+
await expect(topRoomAgain).toBeFocused();
274+
});
255275
});
256276
});
257277

src/components/utils/ListView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ export function ListView<Item, Context = any>(props: IListViewProps<Item, Contex
133133
}
134134
if (items[clampedIndex]) {
135135
const key = getItemKey(items[clampedIndex]);
136-
setTabIndexKey(key);
137136
isScrollingToItem.current = true;
138137
virtuosoHandleRef.current?.scrollIntoView({
139138
index: clampedIndex,
140139
align: align,
141140
behavior: "auto",
142141
done: () => {
142+
setTabIndexKey(key);
143143
isScrollingToItem.current = false;
144144
},
145145
});

0 commit comments

Comments
 (0)