-
Notifications
You must be signed in to change notification settings - Fork 10k
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
confirm if leaving a modified form without saving #12241
Conversation
Relates to #12202. |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @brendandahl received. Current queue size: 0 Live output at: http://54.67.70.0:8877/a56a6e04f9e6b15/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/a56a6e04f9e6b15/output.txt Total script time: 3.34 mins Published |
According to https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event,
Furthermore, years ago, we used to have a All-in-all, it seems really unfortunate as far as I'm concerned to use a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to #12241 (comment), I've also got a couple of questions/suggestions based on a cursory look at the code.
I took a look at this. It looks like |
|
This patch doesn't appear to work. I |
This worked! 488f674 |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @brendandahl received. Current queue size: 0 Live output at: http://54.67.70.0:8877/a63abdef2cb89a4/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/a63abdef2cb89a4/output.txt Total script time: 3.37 mins Published |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me with these comments addressed.
@@ -49,6 +53,9 @@ class AnnotationStorage { | |||
* @param {Object} value | |||
*/ | |||
setValue(key, value) { | |||
if (this._storage.get(key) !== value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only situation where this won't work is
pdf.js/src/display/annotation_layer.js
Line 687 in b061c30
storage.setValue(id, option.displayValue); |
getOrCreateValue
first. You can verify this by opening https://github.com/mozilla/pdf.js/blob/master/test/pdfs/annotation-choice-widget.pdf and without changing anything navigating away from the page, and you'll get the warning.
However, I'll most likely need to change that anyway for #12233, so this should be fine, but I'd like to fix that one first before landing this one just to make sure it's all fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting down to the wire on Firefox's soft freeze coming up. Since the failing behavior isn't too bad, I'm going to merge this in so we have as small as possible updates in mozilla central.
/botio-linux unittest |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @brendandahl received. Current queue size: 0 Live output at: http://54.67.70.0:8877/7d9eb4ffbc0de69/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/7d9eb4ffbc0de69/output.txt Total script time: 3.77 mins
|
Sorry, but I'm finding the decision to add a global event listener in Hence it does seem, at least to me, that placing that code in Also, I understand that the following is more difficult to implement, but nonetheless: Note that this will not warn when switching documents, which means that if you call e.g. |
I thought we might not have an
We may want to file this as an issue to track and prioritize. |
Thank you for your work! The first point is addressed in a follow-up PR and the second point is filed in issue #12257. |
#12241 followup - move event listener to PDFViewerApplication.load
…ion storage This commit makes the following improvements: - The code is similar to the other interactive form widgets now, with a clear note for the only difference. - Calling `getOrCreateValue` unconditionally ensures that choice widgets always have a value in the annotation storage. Previously we only inserted a value in the annotation storage when an option matched or when a selection was changed. However, this causes breakage when saving/printing because comboboxes, which we don't fully support yet but are rendered, might not have a value in storage at all. Their field value might not match any option since it allows the user to enter a custom value. - Calling `getOrCreateValue` unconditionally ensures that forms with choice widgets no longer always trigger a warning when the user navigates away from the page. This fixes mozilla#12241 (comment)
There may be a nicer way to track form modification; not sure.