Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
giphy: Use simplebar to replace browser scrollbar.
Aman Agrawalb1f8041c31cf
diff --git a/static/js/giphy.js b/static/js/giphy.jsindex 132cfca314e..664d50ead22 100644--- a/static/js/giphy.js+++ b/static/js/giphy.js@@ -112,7 +112,7 @@ function update_grid_with_search_term() {if (search_elem.length) {search_term = search_elem[0].value;gifs_grid.remove();- gifs_grid = renderGIPHYGrid($("#giphy_grid_in_popover .popover-content")[0]);+ gifs_grid = renderGIPHYGrid($("#giphy_grid_in_popover .giphy-content")[0]);return;}@@ -123,7 +123,13 @@ function update_grid_with_search_term() {export function hide_giphy_popover() {// Returns `true` if the popover was open.if (active_popover_element) {- active_popover_element.popover("hide");+ // We need to destroy the popover because when+ // we hide it, bootstrap popover+ // library removes `giphy-content` element+ // as part of cleaning up everthing inside+ // `popover-content`, so we need to reinitialize+ // the popover by destroying it.+ active_popover_element.popover("destroy");active_popover_element = undefined;edit_message_id = undefined;return true;@@ -195,7 +201,15 @@ export function initialize() {});active_popover_element.popover("show");- gifs_grid = renderGIPHYGrid($("#giphy_grid_in_popover .popover-content")[0]);+ // Allow simplebar to render, then fetch and+ // render GIFs. otherwise simplebar replaces+ // the `.gipihy-content` element when trying+ // to wrap it and hence, our jquery refernce+ // to `.giphy-content` is lost. Thus, no GIF+ // is rendered.+ setTimeout(() => {+ gifs_grid = renderGIPHYGrid($("#giphy_grid_in_popover .giphy-content")[0]);+ }, 0);$("body").on("keyup",diff --git a/static/styles/popovers.css b/static/styles/popovers.cssindex 423bd2b9c2b..2ca314b4087 100644--- a/static/styles/popovers.css+++ b/static/styles/popovers.css@@ -454,8 +454,9 @@ ul {}#giphy_grid_in_popover {- /* 300px of GIPHY grid + 15px scroll bar width */- width: 315px;+ /* 300px of GIPHY grid + 5px is the extra gutter space+ * between gif columns. */+ width: 305px;border: 0;padding: 0;diff --git a/static/templates/giphy_picker.hbs b/static/templates/giphy_picker.hbsindex 6c6bf309b3e..4be9fb257ae 100644--- a/static/templates/giphy_picker.hbs+++ b/static/templates/giphy_picker.hbs@@ -7,7 +7,13 @@<i class="fa fa-remove" aria-hidden="true"></i></button></div>- <div class="popover-content"></div>+ <div class="popover-content" data-simplebar>+ {{! We need a container we can replace+ without removing the simplebar wrappers.+ We replace the `giphy-content` when+ searching for GIFs. }}+ <div class="giphy-content"></div>+ </div><div class="popover-footer"><img src="/static/images/GIPHY_attribution.png" alt="{{t 'GIPHY attribution' }}"></div>