Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPUB/Snapshot: Keyboard accessibility improvements for annotations #150

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a7a1f05
EPUB/Snapshot: Keyboard accessibility improvements for annotations
AbeJellinek Nov 12, 2024
1b6e437
Fix EPUB find annotation shortcuts
AbeJellinek Nov 13, 2024
27dfbbf
EPUB/Snapshot: Enable annotation focus keyboard navigation
AbeJellinek Nov 14, 2024
98a0867
EPUB/Snapshot: Allow moving note annotations with keyboard
AbeJellinek Nov 14, 2024
9b89847
Only focus elements that are already in view
AbeJellinek Nov 14, 2024
b8d3c77
Calculate focus state lazily
AbeJellinek Nov 14, 2024
74074fd
Fix dummy selection remaining in some cases
AbeJellinek Nov 15, 2024
635dd9e
Prevent scroll on Escape
AbeJellinek Nov 15, 2024
592b03c
Create note in center of screen by default
AbeJellinek Nov 15, 2024
abf7202
Update annotation text when moved/resized via keyboard
AbeJellinek Nov 15, 2024
b8f1c38
Disable annotation creation shortcuts when annotation is selected
AbeJellinek Nov 15, 2024
28fcb83
Fix another case where selection could remain after resize
AbeJellinek Nov 15, 2024
13e00fb
fixup
AbeJellinek Nov 15, 2024
874b6c5
Support up/down resizing
AbeJellinek Nov 15, 2024
75c381d
Skip history when bringing annotation into view
AbeJellinek Nov 15, 2024
534db05
Only navigate if needed
AbeJellinek Nov 15, 2024
1be7418
Hide annotation popup on keyboard resize
AbeJellinek Nov 21, 2024
2875fb0
Show selected annotation popup on Enter
AbeJellinek Nov 21, 2024
ec5e902
Prevent click from focusing annotations
AbeJellinek Nov 21, 2024
8a315ff
Tab out when annotation is selected
AbeJellinek Nov 21, 2024
4095998
Open note annotation popup after creation
AbeJellinek Nov 21, 2024
f16e1c4
Abort if annotation isn't in view
AbeJellinek Dec 6, 2024
43ed28a
Un-break note annotation dragging
AbeJellinek Dec 6, 2024
7159151
EPUB: Potentially prevent invalid annotations
AbeJellinek Dec 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/common/lib/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export function normalizeKey(key, code) {
return key;
}

// Key combination taking into account layout and modifier keys
/**
* Key combination taking into account layout and modifier keys
* @param {KeyboardEvent} event
* @returns {string}
*/
export function getKeyCombination(event) {
let modifiers = [];
if (event.metaKey && isMac()) {
Expand Down Expand Up @@ -86,7 +90,11 @@ export function getKeyCombination(event) {
return modifiers.join('-');
}

// Physical key combination
/**
* Physical key combination
* @param {KeyboardEvent} event
* @returns {string}
*/
export function getCodeCombination(event) {
let modifiers = [];
if (event.metaKey && isMac()) {
Expand Down
3 changes: 2 additions & 1 deletion src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export type FindState = {
total: number,
index: number,
// Mobile app lists all results in a popup
snippets: string[]
snippets: string[],
annotation?: NewAnnotation
} | null;
};

Expand Down
13 changes: 12 additions & 1 deletion src/dom/common/components/overlay/annotation-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,13 @@ let HighlightOrUnderline: React.FC<HighlightOrUnderlineProps> = (props) => {
// the whole outer <g> containing the underline/highlight (potentially small) and the interactive <foreignObject>s
// (big) so that we get all the highlighted text to render in the drag image.
return <>
<g fill={annotation.color} ref={outerGroupRef}>
<g
tabIndex={-1}
onPointerDown={e => e.preventDefault()}
data-annotation-id={annotation.id}
fill={annotation.color}
ref={outerGroupRef}
>
{rectGroup}
{foreignObjects}
{resizer}
Expand Down Expand Up @@ -445,6 +451,7 @@ const Note: React.FC<NoteProps> = (props) => {
opacity={annotation.id ? '100%' : '50%'}
selected={selected}
large={true}
tabIndex={-1}
onPointerDown={onPointerDown && (event => onPointerDown!(annotation, event))}
onPointerUp={onPointerUp && (event => onPointerUp!(annotation, event))}
onContextMenu={onContextMenu && (event => onContextMenu!(annotation, event))}
Expand Down Expand Up @@ -767,6 +774,7 @@ let CommentIcon = React.forwardRef<SVGSVGElement, CommentIconProps>((props, ref)
width={size}
height={size}
viewBox="0 0 24 24"
data-annotation-id={props.annotation?.id}
ref={ref}
>
<IconNoteLarge/>
Expand All @@ -780,6 +788,8 @@ let CommentIcon = React.forwardRef<SVGSVGElement, CommentIconProps>((props, ref)
width={size}
height={size}
className="needs-pointer-events"
tabIndex={props.tabIndex}
data-annotation-id={props.annotation?.id}
>
<div
// @ts-ignore
Expand All @@ -806,6 +816,7 @@ type CommentIconProps = {
opacity?: string | number;
selected?: boolean;
large?: boolean;
tabIndex?: number;
onPointerDown?: (event: React.PointerEvent) => void;
onPointerUp?: (event: React.PointerEvent) => void;
onContextMenu?: (event: React.MouseEvent) => void;
Expand Down
Loading
Loading