sidebar: Allow users to use sidebar search in mobile browser.

It was impossible to search people in mobile browsers because virtual
keyboard used to fire resize event and the function call that we used
to handle this event caused the input field to loose focus and this
made it impossible to type in the people search bar.

The code in this commit fixes this by simply ignoring the resize
events when the user wants to search.

Fixes #11795.
This commit is contained in:
Abhinav Singh
2019-03-07 21:42:42 +05:30
committed by Tim Abbott
parent e9e3eafdde
commit ad336800d0

View File

@@ -48,6 +48,28 @@ function message_hover(message_row) {
}
}
function should_skip_mobile_resize() {
// If we are in the mobile browser then we need to handle resize event
// more carefully because virtual keyboard causes resize event to
// trigger and this leads the input elements to loose focus.
if (util.is_mobile()) {
// If user is trying to search other users in right sidebar
// then don't resize due to opening of virtual keyboard in
// mobile browser because this leads the search bar to loose
// focus and it becomes impossible to type in the input field.
if ($('.user-list-filter').is(':focus')) {
return true;
}
// Don't resize when the user is filtering the streams due to the
// reasons mentioned in the previous comment.
if ($('.stream-list-filter').is(':focus')) {
return true;
}
}
// resize in all other cases.
return false;
}
exports.initialize_kitchen_sink_stuff = function () {
// TODO:
// This function is a historical dumping ground
@@ -83,7 +105,11 @@ exports.initialize_kitchen_sink_stuff = function () {
// preventDefault, allowing the modal to scroll normally.
});
$(window).resize(_.throttle(resize.handler, 50));
$(window).resize(_.throttle(function () {
if (!should_skip_mobile_resize()) {
resize.handler();
}
}, 50));
// Scrolling in overlays. input boxes, and other elements that
// explicitly scroll should not scroll the main view. Stop