Skip to content

Commit ff10687

Browse files
authored
Merge pull request #4196 from ProjectMirador/keyUpThumb
Fix focus and navigation for ThumbnailNavigation
2 parents 25c0b0e + 7af6a1b commit ff10687

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/components/ThumbnailCanvasGrouping.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export class ThumbnailCanvasGrouping extends PureComponent {
6464
role="button"
6565
data-canvas-id={currentGroupings[0].id}
6666
data-canvas-index={currentGroupings[0].index}
67-
onKeyUp={this.setCanvas}
6867
onClick={this.setCanvas}
6968
tabIndex={-1}
7069
sx={theme => ({

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)