From 4601a136a95c6f311be34d44fc7d1c91b3496eb4 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 13 Dec 2017 23:13:35 +0300 Subject: [PATCH] fix the popup width bug in FF when scrollbar is shown * scrollbar width is not subtracted in FF from the actual width * in some versions of FF the paddings should be added on both sides --- popup/search-results.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/popup/search-results.js b/popup/search-results.js index 2c359214..6cf29582 100755 --- a/popup/search-results.js +++ b/popup/search-results.js @@ -111,6 +111,17 @@ window.addEventListener('showStyles:done', function _() { dom.list = $('#search-results-list'); addEventListener('scroll', loadMoreIfNeeded, {passive: true}); + if (FIREFOX) { + addEventListener('resize', () => { + const scrollbarWidth = window.innerWidth - document.scrollingElement.clientWidth; + if (scrollbarWidth !== parseFloat(document.body.style.paddingRight)) { + dom.marginLeft = dom.marginLeft || parseFloat(getComputedStyle(dom.container).marginLeft); + const shift = dom.container.getBoundingClientRect().left - dom.marginLeft; + document.body.style.setProperty('padding', + `0 ${scrollbarWidth - shift}px 0 ${shift}px`, 'important'); + } + }); + } addEventListener('styleDeleted', ({detail}) => { const entries = [...dom.list.children];