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

Conversation

AbeJellinek
Copy link
Member

Implements relevant #138 for EPUB/snapshot. Supports creating/resizing highlight/underline/note annotations.

@AbeJellinek AbeJellinek requested a review from mrtcode November 12, 2024 17:14
@mrtcode
Copy link
Member

mrtcode commented Nov 13, 2024

Looks pretty good, but there are a few things to think about:

  1. onSetFindPopup doesn't seem to receive result.annotation, so creating annotations from the find input doesn't work.
  2. Note annotations can only be created with keyboard when text is selected, and there is no way to move them afterward, right?
  3. Also, navigating visible annotations and links with Tab and arrow keys seems to be necessary thing for accessibility, isn't it?

@AbeJellinek
Copy link
Member Author

onSetFindPopup doesn't seem to receive result.annotation, so creating annotations from the find input doesn't work.

It was working in snapshots already; fixed for EPUBs.

Note annotations can only be created with keyboard when text is selected, and there is no way to move them afterward, right?

Currently, yes. We could support shortcuts that move them between block elements. I'm a little skeptical about how well it'll work, but at least it'll be easier than deleting and recreating.

Also, navigating visible annotations and links with Tab and arrow keys seems to be necessary thing for accessibility, isn't it?

Yes, definitely. I forgot that those changes were part of #138; I'll get on porting those over to EPUB/snapshot.

@AbeJellinek
Copy link
Member Author

Do we want 2D navigation in EPUB/snapshot? I'm sort of inclined toward no, since it feels a little weird for textual web content (which has a linear order built in, unlike some PDFs), but no strong opinion.

@mrtcode
Copy link
Member

mrtcode commented Nov 13, 2024

Yeah, I think 1D navigation is sufficient to start.

@AbeJellinek
Copy link
Member Author

OK, could you give it another try? Arrow key navigation and note annotation moving should work now.

@mrtcode
Copy link
Member

mrtcode commented Nov 14, 2024

Sure. Looks great, but there are still a few things:

Shift-Option-ArrowLeft results in this issue for me:

1.mov

Tab -> Enter -> Escape scrolls the view to the top instead of defocusing the currently focused annotation:

2.mov

I'm not sure if this is an issue, but when Caps Lock is on, I see that blue icon whenever I click on text:

3.mov

So is there a way to create a note annotation with just keyboard?

@AbeJellinek
Copy link
Member Author

OK, those issues should be fixed.

So is there a way to create a note annotation with just keyboard?

Ctrl-Alt-3 will now create a note annotation in the middle of the screen if there isn't any text selected.

I'm not sure if this is an issue, but when Caps Lock is on, I see that blue icon whenever I click on text

macOS bug. I don't know why it's showing in this particular iframe, since nothing there should be sent to contenteditable. I just fully disabled it on my non-work machine: https://gist.github.com/stephancasas/236f543b0f9f6509f5fe5878de01e38a

@AbeJellinek
Copy link
Member Author

@mrtcode: Could you give this another try when you have a chance and let me know if anything seems to be missing?

@mrtcode
Copy link
Member

mrtcode commented Nov 20, 2024

Sorry for the delay.

A few little observations:

Should the annotation popup hide when resizing a highlight?

An extra tab is needed to focus on the annotation popup:

extra-tab.mov

Annotation movement with Shift-ArrowKeys is intentionally different from PDF view to prevent accidental movement, right?

After adding a note annotation with Ctrl-Option-3, the annotation is focused, but the popup doesn't appear.

@AbeJellinek
Copy link
Member Author

Annotation movement with Shift-ArrowKeys is intentionally different from PDF view to prevent accidental movement, right?

How's that?

I'll fix the popup bugs. Thanks - don't test with the sidebar closed enough.

@mrtcode
Copy link
Member

mrtcode commented Nov 20, 2024

Annotation movement with Shift-ArrowKeys is intentionally different from PDF view to prevent accidental movement, right?

How's that?

Sorry. I mean Note annotation movement to another paragraph.

@AbeJellinek
Copy link
Member Author

Oh, that wasn't exactly intentional (although maybe I'm just forgetting my reasoning), but I think it does make sense. EPUB/snapshot note annotations are annotations on text, not freeform annotations on the page, so I think it makes sense for them to move like highlights.

@AbeJellinek
Copy link
Member Author

Should all be fixed.

@mrtcode
Copy link
Member

mrtcode commented Nov 22, 2024

Almost perfect. Just one more thing.

After moving (with Shift-ArrowKeys) the note annotation across paragraphs, it disappeared, and I now get this error:

Unable to get range for CFI epubcfi(/6/14!/,/1:1,/5:0) TypeError: step is undefined
    stepsToXpath resource://zotero/reader/reader.js:28614
    stepsToXpath resource://zotero/reader/reader.js:28613
    findNode resource://zotero/reader/reader.js:28713
    toRange resource://zotero/reader/reader.js:28782
    getRange resource://zotero/reader/reader.js:39162
    navigate resource://zotero/reader/reader.js:39845
    _navigateToSelector resource://zotero/reader/reader.js:39239
    navigate resource://zotero/reader/reader.js:37507
    navigate resource://zotero/reader/reader.js:39888
    setSelectedAnnotations resource://zotero/reader/reader.js:51681
    handleSidebarAnnotationSectionClick resource://zotero/reader/reader.js:24081
    handleSectionClick resource://zotero/reader/reader.js:23521
    onClick resource://zotero/reader/reader.js:23671
    React 15

@AbeJellinek
Copy link
Member Author

Uh oh. Which EPUB/snapshot? And where was the note? I'll see if I can reproduce.

@mrtcode
Copy link
Member

mrtcode commented Nov 22, 2024

This EPUB file. Just add a note annotation and hold Shift-ArrowDown until it crashes at some paragraph.

@AbeJellinek AbeJellinek force-pushed the dom-accessibility-annotations branch from 4aa2885 to 7159151 Compare December 6, 2024 17:34
@AbeJellinek
Copy link
Member Author

I haven't been able to reproduce that, unfortunately... but I added a few checks that might prevent it. Could you see if it's still happening?

@mrtcode
Copy link
Member

mrtcode commented Dec 6, 2024

I no longer get the error. Now it just stops moving to the next paragraph where it was disappearing before, so I assume it’s fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants