pl-fe: allow accessing 'load more' button with hotkeys

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-10-31 11:02:41 +01:00
parent 83d2bc1073
commit e1986fb670
11 changed files with 25 additions and 14 deletions

View File

@ -1,7 +1,15 @@
import type React from 'react';
import type { VirtuosoHandle } from 'react-virtuoso';
const selectChild = (index: number, handle: React.RefObject<VirtuosoHandle>, node: ParentNode = document) => {
const selectChild = (index: number, handle: React.RefObject<VirtuosoHandle>, node: ParentNode = document, count?: number) => {
if (count !== undefined && index === count) {
const loadMoreButton = node.querySelector<HTMLButtonElement>('.⁂-load-more');
if (loadMoreButton) {
loadMoreButton.focus({ preventScroll: false });
return;
}
}
const selector = `[data-index="${index}"] .focusable`;
const element = node.querySelector<HTMLDivElement>(selector);