-
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
Populate the find field with the search query when URL has #search hash #12141
Populate the find field with the search query when URL has #search hash #12141
Conversation
These changes improves the existing search functionality triggered when the URL contains a `#search` hash. In addition to performing the actual search immediately like before, this will ensure the search text field inside the find bar gets populated with the text currently being searched for.
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/400325baad11d3d/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/400325baad11d3d/output.txt Total script time: 3.36 mins Published |
Looks good to me. Thank you! |
Appreciate the quick response! Just noticed what gives an impression Line 33 in c5663f2
Would that ever happen in practise when |
Sorry, but why was this patch accepted when it introduces inconsistent behaviour depending on Previously we've rejected these kind of changes, because of the inconsistency they would bring, especially considering that this (for security reason) cannot be easily implemented in the Firefox PDF viewer; please note prior discussion in e.g. issues #3565, #8185, and #9831. |
@Snuffleupagus I wasn't aware of those concerns, thanks for bringing that up. Sounds like these changes as is should be reverted from Do you have any advice for me to work on improvements that addresses these inconsistencies? Alternatively your recommended approach for doing what was intended with these changes? |
This obviously isn't a huge and/or breaking change, so I don't know what the consensus will be regarding a back-out. Hence I suppose that this could stay, as far I'm concerned, if and only if:
I don't think there's a good/secure way of handling this generally, in the Firefox browser findbar as well, since #3565 (comment) ought to apply here as well (having a web-page control the contents of the browser findbar seems wrong). |
As I obviously can't comment on if's your raising, I can at least share the use case we've got in the project I'm working on -- consider or ignore as you please. Our end-users finds PDF documents either by navigating to them or as part of the product's search results. The off the shelf Viewer is embedded via an Without the changes in this PR, the user experience is not totally intuitive though. End-users obviously appreciate the convenience of text matches being highlighted right away. But it's confusing when they open the find bar and the text field is empty -- although it is has obviously searched for something seeing text is highlighted (like Inspired by the Third party viewer usage wiki I've found another workaround which isn't too bad. Though from a PDF.js rookie and using-project's perspective, it is still awkward that code needs to be written fill in the find text field 🤷♂️ document.addEventListener("webviewerloaded", function(event) {
const PDFViewerApplication = event.detail.source.PDFViewerApplication;
PDFViewerApplication.initializedPromise.then(function() {
PDFViewerApplication.findBar.findField.value = "tesla"; // same value as provided in URL's #search hash
});
}); Would you be more positive to these changes if they were located in |
That would be a lot worse, in every way, given that There's only one decision to be made here: Either we let these changes stay as-is (since it's a small patch), or we revert them wholesale (and reject any future attempt at changing this).
Sorry, I really don't understand this question. |
I forgot about the integrated findbar here; sorry for that. I do think that the change makes sense because having a search query enabled yet not seeing it in the findbar is indeed inconsistent. However you have a valid point about us rejecting such changes before, so making an exception in this case would also be inconsistent. I'll make a PR to revert this change for now and open an issue where we can discuss how to move forward with the findbar since I do feel that the lack of customizability of the integrated one is holding us back sometimes as evidenced by the various PRs that were made before. I personally don't mind them being a bit inconsistent because they are never used together, but I think this is a discussion for outside of this PR. |
Completely agreed; I've never questioned the utility of the feature itself, just how it's implemented (or not) across various build targets.
Agreed, and in this case the difference is small enough to probably not matter much... It should be possible, without too much trouble, to support pre-populating the Firefox findbar only when |
…earch hash" This reverts commit 50f7309. This causes an inconsistency with the integrated find bar that should be discussed more before moving on with this (refer to PR mozilla#12141).
Sounds good to have a dedicated discussion settling the overall policy for find bar changes and behaviour going forward 👍 I won't be participating in the discussion as my PDF.js incompetence is obvious. Feel free to ping me if you want input from an using project' point of view. |
It is possible to do it this way
|
These changes improves the existing search functionality triggered when the URL contains a
#search
hash.In addition to performing the actual search immediately like before, this will ensure the search text field inside the find bar gets populated with the text currently being searched for.
Picture says more than a thousand words; the goal is for
tesla
being populated in the search field below because pdf.js was loaded with#search=tesla
in the URL:Does this look like a viable approach to you?
Kudos to @marill for finding this workaround.