-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
[JS] Hide field borders and buttons (#15053) #15054
Conversation
@@ -570,6 +570,7 @@ class LinkAnnotationElement extends AnnotationElement { | |||
render() { | |||
const { data, linkService } = this; | |||
const link = document.createElement("a"); | |||
link.setAttribute("id", data.id); |
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.
Why is this necessary, since all containers already provide that information in a data-annotation-id
attribute and I cannot immediately tell where in this patch (or the tests) this is even being used?
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 "need" it here:
pdf.js/web/pdf_scripting_manager.js
Line 354 in b9f5a70
const element = document.getElementById(elementId); |
Most of (all?) the actions have an impact on the field's HTML counterpart (e.g. textarea/input for a text field) so it's why I originally decided to use the id
: my idea was to directly have the element which will receive the change.
And I think it wasn't so bad.
I added the id
on the a
just to be consistent with what we've for other containers.
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.
Actually, the potentially annoying part of adding id
s to these elements is that they become "linkable" through the URL hash in a way that's not supported/intended (see issue #11499 and PR #11503 for some context).
These id
s could potentially clash with named destinations, and by adding this to all link elements these issues could very well become more common. I wonder if there's a better way, in general for all annotations, to handle things rather than using id
s like this!?
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.
At least from a JS pov, I think we can get rid of it easily: we could select the section
with the correct data-annotation-id
which will itself update the correct child.
I wonder if it could have a measurable impact on perf: query selector vs getElementById and then go to the child...
Anyway I played /f1040.pdf#208R
(an annotation on the bottom of page 2) and the form is scrolled...
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.
I wonder if it could have a measurable impact on perf: query selector vs getElementById and then go to the child...
My gut feeling is that query-selector probably is slower in general :-(
Although we're already using that in some parts of the AnnotationLayer-code, see
pdf.js/src/display/annotation_layer.js
Lines 2506 to 2508 in b9f5a70
const elements = div.querySelectorAll( | |
`[data-annotation-id="${data.id}"]` | |
); |
pdf.js/src/display/annotation_layer.js
Line 2553 in b9f5a70
const element = div.querySelector(`[data-annotation-id="${id}"]`); |
Anyway I played
/f1040.pdf#208R
(an annotation on the bottom of page 2) and the form is scrolled...
Which it obviously shouldn't :-)
As mentioned that may cause some trouble if the document has a "named destination" which happens to be called 208R.
Anyway, we obviously don't have to try and fix all of that right now here in this patch!
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.
I filed a bug:
#15056
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.
r=me, with the comment addressed and passing tests; thank you!
src/display/annotation_layer.js
Outdated
this._setDefaultPropertiesFromJS(container.lastChild); | ||
|
||
container.lastChild.addEventListener("updatefromsandbox", jsEvent => { |
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.
To make it a bit clearer which element this actually references, how about something like the following (assuming that I'm understanding the code correctly)?
this._setDefaultPropertiesFromJS(container.lastChild); | |
container.lastChild.addEventListener("updatefromsandbox", jsEvent => { | |
const linkElement = container.lastChild; | |
this._setDefaultPropertiesFromJS(linkElement); | |
linkElement.addEventListener("updatefromsandbox", jsEvent => { |
- Since the border belongs to the section containing the HTML counterpart of an annotation, this section must be hidden when a JS action requires it; - it wasn't possible to hide a button in using JS.
/botio unittest |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/f6d856d940d93d1/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/b907c49ad0f2a8c/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/b907c49ad0f2a8c/output.txt Total script time: 3.21 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/f6d856d940d93d1/output.txt Total script time: 6.47 mins
|
/botio integrationtest |
From: Bot.io (Linux m4)ReceivedCommand cmd_integrationtest from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/ab86d80632acccf/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_integrationtest from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/53d4ed3ef1a1a1f/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/ab86d80632acccf/output.txt Total script time: 4.49 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/53d4ed3ef1a1a1f/output.txt Total script time: 7.73 mins
|
counterpart of an annotation, this section must be hidden when
a JS action requires it;