-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Viewer: enable find functionality for small devices #8132
Viewer: enable find functionality for small devices #8132
Conversation
23e13b6
to
0e72e5e
Compare
This looks a lot cleaner than the previous solution, which is really nice!
|
0e72e5e
to
8227a18
Compare
I did look into that, but I really think there is nothing we can do about that. It looks like it's because the find dialog has an absolute position, in which case the browser attempts to use the full width unless a fixed width is specified, which we don't want for the reponsiveness. As you said in #6274 (comment), I also think we need to live with that, and I personally don't find it too much of an issue because usually the space is used reasonably well by all elements.
You're right. I reverted that changed and enforced a 32 pixel height for all findbar container |
/botio-linux preview |
Well, if we just use a little bit of JavaScript that runs only when the findbar is opened (and when the viewer resizes while the findbar is open), then I think that could actually be doable :-) |
Do you mean something like https://github.com/mozilla/pdf.js/blob/master/web/secondary_toolbar.js#L225, but then for the find bar width? If so, I think that should be fine. I do wonder what width we would set in this case, because the width has to be determined automatically based on the contents. Do you have an idea how to do that? |
A very quick proof-of-concept idea: https://gist.github.com/Snuffleupagus/f8640bb3a742fc8f9bed26c6b7c98e5d. |
<label for="findHighlightAll" class="toolbarLabel" data-l10n-id="find_highlight">Highlight all</label> | ||
<input type="checkbox" id="findMatchCase" class="toolbarField" tabindex="95"> | ||
<label for="findMatchCase" class="toolbarLabel" data-l10n-id="find_match_case_label">Match case</label> | ||
<span id="findResultsCount" class="toolbarLabel hidden"></span> |
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.
Perhaps it'd make sense to place this in the findbarMessageContainer
instead?
Especially since I seem to recall a WIP PR that wanted to add a checkbox for toggling "phrase/word" search, in which case the resultsCount
might not fit here any more.
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 think you're right. I'll change that.
web/viewer.html
Outdated
</button> | ||
<div class="findbar hidden doorHanger" id="findbar"> | ||
<div id="findbarLabelContainer"> | ||
<label for="findInput" class="toolbarLabel" data-l10n-id="find_label">Find:</label> |
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'm not sure that I understand why the label
is in it's own container here, would you mind explaining why it's not just placed in the findInputContainer
instead?
Ninja edit: Oh, I suppose that you may be worried about the different lengths of the label depending on the locale and that it might not fit inside of the min-width
otherwise?
One way to solve that, inspired by e.g. the Firefox built-in findbar, and the fact that we don't use labels in the main UI (i.e. not for e.g. the pageNumber nor the zoomDropdown), could be to replace the label with a placeholder
in the input instead.
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.
Looking through my local patches/diffs, I actually found this https://gist.github.com/Snuffleupagus/cbba3a6823c3a02a59a1a1d8bcbe6059. As far as I can tell I never submitted a PR for that, but if memory serves it worked just 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.
Yes, I put that in its own label because of the length of the "Search" label in different locales. I actually really like the placeholder idea, so I'll check if that works.
8227a18
to
e46eb8e
Compare
I have included your two patches to convert the label to a placeholder/tootip and to fix the problem of find bar width being too large. Moreover, I added a bit of CSS to prevent issues with long find messages on small screens (especially for the Dutch locale with its long strings). The only thing I couldn't do is move the find count to the find message container as that gives some strange wrapping when the screen becomes smaller (at least for the Dutch locale). This may be addressed in a follow-up patch though for when additional checkboxes are added. |
/botio-linux preview |
e46eb8e
to
c218958
Compare
/botio-linux preview |
I've done some quick testing in Firefox, Chrome and IE (on Windows) with the latest version of the PR, and everything seems to work as it should. I also tested RTL a bit, and couldn't find any issues there either. The only other thing that we might want to consider (as mentioned on IRC), now that the variability of the "Find" label is gone, is to maybe increase the width of the Find input a bit!? Another question (adding it here since using inline comments just marked it as "outdated"): |
web/pdf_find_bar.js
Outdated
var inputContainerHeight = this.bar.firstElementChild.clientHeight; | ||
|
||
if (findbarHeight > inputContainerHeight) { | ||
// The findbar is higher than the input container, which means that |
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.
Nit: I think you want to use taller
(instead of higher).
web/pdf_find_bar.js
Outdated
|
||
// The find bar has an absolute position and thus the browser extends | ||
// its width to the maximum possible width once the find bar does not fit | ||
// entirely within the window anymore (and needs to be wrapped). Here we |
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.
Nit: Maybe ... (and parts/all of it is automatically wrapped)...
or something instead, since the wrapping is automatic based on the CSS.
c218958
to
aea9cf4
Compare
/botio-linux preview |
This is common in the rest of the UI and helps us prevent responsiveness issues for different length strings in different locales.
The find functionality is currently not available for small devices because the find dialog is not responsive. This patch fixes that. To achieve this goal, the HTML is changed to always show the find button. To prevent issues because of the addition of an extra button for small views, the previous/next page buttons are hidden if the view becomes small. These buttons are not useful anyway because on small devices navigation is usually done via scrolling. The find functionality is much more useful to have in this case. Moreover, we wrap the existing elements into separate `div`s so that the browser can position the elements itself when the view becomes smaller and logically connected elements stay together when this happens. In the CSS, extra rules for the find bar have been added to ensure that the dialog's doorhanger is always below the find button. All findbar `div`s are forced to be 32 pixels high to prevent the find message text being aligned under the checkboxes. Finally, the find message is only visible when there is actually text to display. This prevents wrapping issues because, by default, the label has padding and margin even if there is no text.
This patch ensures that the find bar is not extended to the window width when element wrapping occurs on small screens.
aea9cf4
to
b151666
Compare
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/00208934cb71170/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/00208934cb71170/output.txt Total script time: 2.16 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.
(This should have been type "approved" instead of "comment", but it doesn't seem that can be changed.)
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.
This looks much better than the current unresponsive findbar; thanks for seeing this work through!
I obviously cannot review the parts I helped write, but the rest looks good to me :-)
Should we just land this, or do we want to wait until e.g. tomorrow to have a bit more time to play with the PR before merging?
…ness Viewer: enable find functionality for small devices
The commit messages provide more information about the intent of each patch.
This PR is a re-do of #6274, so please refer to that PR for previous discussion on this subject. This patch aims to resolve the issues mentioned there while keeping the code changes minimal.
Fixes #6191.
Supersedes #6274.
Reviewing is easier with https://github.com/mozilla/pdf.js/pull/8132/files?w=1.