Skip to content

Commit 226ed77

Browse files
committed
fix(a11y): let Escape deselect in the PDF text editor
Clicking the page backdrop clears the current selection, but that path is mouse-only — a keyboard user had no way out of a selection at all. The backdrop stays a plain surface rather than becoming a control; it is a canvas, not a button.
1 parent 83ef53b commit 226ed77

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

frontend/editor/src/core/components/tools/pdfTextEditor/PdfTextEditorView.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,17 @@ const PdfTextEditorView = ({ data }: PdfTextEditorViewProps) => {
14061406
clearSelection();
14071407
};
14081408

1409+
// Clicking the page backdrop deselects, but that is mouse-only: without this
1410+
// a keyboard user has no way out of a selection. The backdrop itself stays a
1411+
// plain surface — it is a canvas, not a control.
1412+
useEffect(() => {
1413+
const onKeyDown = (event: KeyboardEvent) => {
1414+
if (event.key === "Escape") handleBackgroundClick();
1415+
};
1416+
window.addEventListener("keydown", onKeyDown);
1417+
return () => window.removeEventListener("keydown", onKeyDown);
1418+
});
1419+
14091420
const handleSelectionInteraction = useCallback(
14101421
(groupId: string, groupIndex: number, event: React.MouseEvent): boolean => {
14111422
const multiSelect = event.metaKey || event.ctrlKey;

0 commit comments

Comments
 (0)