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

Annotation deletion popup (bug 1899731) #18900

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

ryzokuken
Copy link
Collaborator

This PR adds a simple popup/snackbar setup and wires it up for annotation removal, so when a user deletes any number of annotations, they get a message about it alongside an undo button that allows them to quickly undo the deletion.

@ryzokuken ryzokuken force-pushed the popup-undo-annotation branch from ebf8d04 to ae79bee Compare October 14, 2024 14:45
Copy link
Contributor

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need tests in the various editors, in https://github.com/mozilla/pdf.js/tree/master/test/integration, or maybe its own new test file that tests that the toast is properly shown in the various cases.

src/display/editor/tools.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this perhaps related to https://bugzilla.mozilla.org/show_bug.cgi?id=1899731, since there seems to be no mention of that bug here?

Please note that we'll need a "full" design specification before implementing this, and given its current state the code will also require a fair amount of work here (as far as I can tell).

web/message_bar.css Outdated Show resolved Hide resolved
@marco-c marco-c changed the title Annotation deletion popup Bug 1899731 - Annotation deletion popup Oct 14, 2024
@marco-c marco-c changed the title Bug 1899731 - Annotation deletion popup Annotation deletion popup (bug 1899731) Oct 14, 2024
@marco-c
Copy link
Contributor

marco-c commented Oct 14, 2024

Is this perhaps related to https://bugzilla.mozilla.org/show_bug.cgi?id=1899731, since there seems to be no mention of that bug here?

Please note that we'll need a "full" design specification before implementing this, and given its current state the code will also require a fair amount of work here (as far as I can tell).

I added a link to the Figma specs in the bug. It should be accessible to all of you (let me know if you don't have access, and I'll get you added).

web/viewer.html Outdated Show resolved Hide resolved
web/message_bar.css Show resolved Hide resolved
web/message_bar.css Outdated Show resolved Hide resolved
web/pdf_viewer.css Outdated Show resolved Hide resolved
@nicolo-ribaudo
Copy link
Contributor

nicolo-ribaudo commented Oct 14, 2024

@calixteman @Snuffleupagus Please wait to review until when this PR is marked as ready -- I am giving some feedback to @ryzokuken to make sure that it matches correctly what is defined in the figma doc :)

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving just a few high-level comments regarding things/patterns that should be improved.

l10n/en-US/viewer.ftl Outdated Show resolved Hide resolved
src/display/editor/tools.js Outdated Show resolved Hide resolved
web/message_bar.css Outdated Show resolved Hide resolved
web/pdf_viewer.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/viewer.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
ryzokuken added a commit to ryzokuken/pdf.js that referenced this pull request Oct 14, 2024
This is a temporary commit on this branch that aims to address some of the review comments from the PR at mozilla#18900.
@ryzokuken
Copy link
Collaborator Author

First off, thanks everyone for all the comments it's nice to have a stronger sense of direction as to where I need to take this patch. I addressed some of the comments y'all made and marked the appropriate suggestions as "resolved" although please feel free to re-raise anything.

To respond to the questions:

Is this perhaps related to bugzilla.mozilla.org/show_bug.cgi?id=1899731, since there seems to be no mention of that bug here?

Please note that we'll need a "full" design specification before implementing this, and given its current state the code will also require a fair amount of work here (as far as I can tell).

Yes it is! Thanks @marco-c for the clarification and sharing the spec. Regarding the code, I hope the bigger pain points have either already been addressed or I'd be hacking on them shortly.

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on looking at the code, I believe that there's various cases where the notification won't be closed immediately as I believe is intended when:

  • Restoring the editor with Ctrl+Z (i.e. using the keyboard).
  • Toggling editing-mode off.
  • The entire editorLayer is being destroyed (i.e. when closing the current PDF document).

web/toast_manager.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/viewer.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
web/toast_manager.js Outdated Show resolved Hide resolved
@ryzokuken
Copy link
Collaborator Author

@Snuffleupagus

(I don't know what setInterval has to do with this, since that's not related to the issue I mentioned above.)

Apologies, I misunderstood your comment at first. Applied the fix that you'd ultimately suggested.

I've marked a number of your comments as resolved, please take a look and let me know if I missed something from my latest commit while I work on addressing the remaining issues. Thanks again for your patience.

web/viewer.html Outdated Show resolved Hide resolved
web/message_bar.css Outdated Show resolved Hide resolved
web/message_bar.css Outdated Show resolved Hide resolved
web/viewer.html Outdated Show resolved Hide resolved
web/viewer.html Outdated Show resolved Hide resolved
web/viewer.js Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
l10n/en-US/viewer.ftl Outdated Show resolved Hide resolved
@ryzokuken
Copy link
Collaborator Author

@Snuffleupagus thanks for the last slew of suggestions especially, it taught me a lot about the code and fixed the l10n bug. The code should ideally look much more manageable now. While I make more improvements and add tests, please let me know if you have any further comments.

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing that I think should be supported is closing the undo-bar with the Esc key, and the easiest solution would be to (after implementing the comments below) also add the following code just after this existing code:

if (this.editorUndoBar?.isOpen) {
  this.editorUndoBar.hide();
  handled = true;
}

web/message_bar.css Outdated Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
@ryzokuken
Copy link
Collaborator Author

I added the ESC key dismiss thingie but note that it's not part of the Figma spec which says:

The message bar should persist on screen until:

  • User clicks “X” close
  • User creates a new annotation
  • User opens Print dialog
  • User opens Save dialog
  • User selects an option from the “more” menu
  • User closes tab
  • User closes session

Maybe we should get the ESC key condition added there.

@Snuffleupagus
Copy link
Collaborator

I added the ESC key dismiss thingie but note that it's not part of the Figma spec which says:

The message bar should persist on screen until:

[...]

Note also the other cases mentioned previously in #18900 (review), maybe those should be added to that list as well?

@ryzokuken
Copy link
Collaborator Author

Absolutely, I'll mention this to the UX folks.

web/editor_undo_bar.js Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
@ryzokuken
Copy link
Collaborator Author

Good point, I cleaned up the class fields and simplified the constructor a bit.

@ryzokuken ryzokuken force-pushed the popup-undo-annotation branch from a4130d0 to 13d7c53 Compare October 18, 2024 02:16
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/a89f9f5cd81ab10/output.txt

Total script time: 0.97 mins

Published

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Nov 27, 2024

It's not possible to use the keyboard to "click" on the Undo-button, since tabbing to it and then pressing either Enter or Space doesn't work (the undo-bar is hidden, but the editor isn't restored).

@calixteman
Copy link
Contributor

@ryzokuken could you fix the bug mentioned in #18900 (comment) ? and add a test (just for one kind of editor) to check that "clicking" on undo with the keyboard is working as expected. Thank you.

@ryzokuken ryzokuken force-pushed the popup-undo-annotation branch from aad4978 to 54423d7 Compare November 30, 2024 02:22
@ryzokuken
Copy link
Collaborator Author

@calixteman okay should be fixed now, also addressed your suggestion about moving out editorSelector.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Nov 30, 2024

okay should be fixed now,

Unfortunately that's not the case, since there's various problems with the latest update:

  • Spacebar can also be used to "click" with the keyboard.
  • Ignoring those keys in the onKeyDown handler means that if focus is outside of the undo-bar then it won't be closed as intended in all situations.

@ryzokuken ryzokuken force-pushed the popup-undo-annotation branch from 54423d7 to be23449 Compare December 2, 2024 22:00
Move .messageBar out of .dialog into its own standalone class in order
to reuse as much of it for the upcoming feature for an undo message for
annotations.
@ryzokuken ryzokuken force-pushed the popup-undo-annotation branch from be23449 to f073c4e Compare December 2, 2024 22:03
@ryzokuken
Copy link
Collaborator Author

Fixed the bug, added tests to check for that specific behavior and rebased again. How does it look?

src/display/editor/annotation_editor_layer.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
web/editor_undo_bar.js Outdated Show resolved Hide resolved
test/integration/highlight_editor_spec.mjs Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
@ryzokuken ryzokuken force-pushed the popup-undo-annotation branch from f073c4e to 6a63b8c Compare December 3, 2024 00:06
@ryzokuken
Copy link
Collaborator Author

@Snuffleupagus thanks for the comments! Fixed now.

@Snuffleupagus
Copy link
Collaborator

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/fdac611ab9f1b82/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/13ae1aa12966894/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/fdac611ab9f1b82/output.txt

Total script time: 10.50 mins

  • Integration Tests: FAILED

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/13ae1aa12966894/output.txt

Total script time: 22.43 mins

  • Integration Tests: FAILED

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, with one more suggestion.

web/app.js Outdated Show resolved Hide resolved
ryzokuken and others added 2 commits December 3, 2024 11:03
When a user deletes any number of annotations, they are notified of the action
by a popup message with an undo button. Besides that, this change reuses the
existing messageBar CSS class from the new alt-text dialog as much as possible.
@ryzokuken ryzokuken force-pushed the popup-undo-annotation branch from 6a63b8c to 41bf874 Compare December 3, 2024 10:03
Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

@calixteman calixteman merged commit a5ce712 into mozilla:master Dec 3, 2024
10 checks passed
calixteman added a commit to calixteman/pdf.js that referenced this pull request Dec 4, 2024
calixteman added a commit that referenced this pull request Dec 4, 2024
Fix unused css variables (follow-up of #18900)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants