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

Search Widget occurence navigation not working when using "search" hash parameter. #8185

Open
ghost opened this issue Mar 22, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 22, 2017

Link to PDF file (or attach file here):
Can be reproduced using the demo / sample : https://mozilla.github.io/pdf.js/web/viewer.html#search=language

Configuration:

  • Web browser and its version:
    Any
  • Operating system and its version:
    Any
  • PDF.js version:
    Found in latest stable (v1.6.210), reproducible in online demo (1.7.378)
  • Is an extension:
    No

Steps to reproduce the problem:

  1. Use a url with search param : https://mozilla.github.io/pdf.js/web/viewer.html#search=language
  2. Open the search widget (with the intention of using "next occurence" by exemple).

What is the expected behavior? (add screenshot)

  • Clicking on "next occurence" should be working.
  • The current active search term should be visible instead of place holder "Find in document...".

What went wrong? (add screenshot)

  • Previous / next occurence are not working.
  • Current search term is not visible.

screen shot 03-22-17 at 02 14 pm

@ghost
Copy link
Author

ghost commented Mar 22, 2017

It's probably not the clean solution (should be done within findfromurlhash handler?) but I have patched our local version with this :

    setHash: function PDFLinkService_setHash(hash) {
      var pageNumber, dest;
      if (hash.indexOf('=') >= 0) {
        var params = parseQueryString(hash);
        if ('search' in params) {

          // If search param exist. Set it in Search bar find field.
          // So that the user can use next occurent as expected.
          var searchText = params['search'].replace(/"/g, '');
          if (searchText) {
            PDFViewerApplication.findBar.findField.value = searchText;
          }

          this.eventBus.dispatch('findfromurlhash', {
            source: this,
            query: searchText,
            ...

@yurydelendik
Copy link
Contributor

See also #5579 (comment)

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

No branches or pull requests

2 participants