Skip to content

Commit 7af6a1b

Browse files
committed
Force focus on ThumbnailNavigation during canvas re-rendering
1 parent eee60e2 commit 7af6a1b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/components/ThumbnailNavigation.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ export function ThumbnailNavigation({
3434
gridRef.current?.scrollToItem(index, 'center');
3535
}, [canvasIndex, view]);
3636

37+
// Prevent loss of focus when navigating thumbnails
38+
const paperRef = useRef(null);
39+
40+
useEffect(() => {
41+
if (paperRef.current && document.activeElement !== paperRef.current) {
42+
paperRef.current.focus();
43+
}
44+
}, [canvasIndex]);
45+
3746
/** */
3847
const handleKeyDown = (e) => {
3948
let nextKey = 'ArrowRight';
@@ -166,6 +175,7 @@ export function ThumbnailNavigation({
166175
tabIndex={0}
167176
onKeyDown={handleKeyDown}
168177
role="grid"
178+
ref={paperRef}
169179
>
170180
<div role="row" style={{ height: '100%', width: '100%' }}>
171181
{ canvasGroupings.length > 0 && (
@@ -183,6 +193,7 @@ export function ThumbnailNavigation({
183193
layout={(position === 'far-bottom') ? 'horizontal' : 'vertical'}
184194
itemData={itemData}
185195
ref={gridRef}
196+
itemKey={(index) => index}
186197
>
187198
{ThumbnailCanvasGrouping}
188199
</List>

0 commit comments

Comments
 (0)