pl-fe: allow accessing 'load more' button with hotkeys
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user