From ffeef695fa3db060747b82b1138e6e7d92c86704 Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 17 Nov 2020 22:47:14 +0300 Subject: [PATCH] simplify adjustWidth and make it work in FF --- manage/filters.js | 23 +++++++++++------------ manage/manage.css | 4 ---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/manage/filters.js b/manage/filters.js index e844f852..0e2b2700 100644 --- a/manage/filters.js +++ b/manage/filters.js @@ -23,18 +23,17 @@ router.watch({search: ['search', 'searchMode']}, ([search, mode]) => { }); HTMLSelectElement.prototype.adjustWidth = function () { - const option0 = this.selectedOptions[0]; - if (!option0) return; - const parent = this.parentNode; - const singleSelect = this.cloneNode(false); - singleSelect.style.width = ''; - singleSelect.appendChild(option0.cloneNode(true)); - parent.replaceChild(singleSelect, this); - const w = singleSelect.offsetWidth; - if (w && this.style.width !== w + 'px') { - this.style.width = w + 'px'; - } - parent.replaceChild(this, singleSelect); + const sel = this.selectedOptions[0]; + if (!sel) return; + const wOld = parseFloat(this.style.width); + const opts = [...this]; + opts.forEach(opt => opt !== sel && opt.remove()); + this.style.width = ''; + requestAnimationFrame(() => { + const w = this.offsetWidth; + if (w && wOld !== w) this.style.width = w + 'px'; + this.append(...opts); + }); }; function initFilters() { diff --git a/manage/manage.css b/manage/manage.css index 4cbf38a2..1f03f0c4 100644 --- a/manage/manage.css +++ b/manage/manage.css @@ -1200,10 +1200,6 @@ a:hover { padding-left: 0; } - #reset-filters { - margin-top: 4px; - } - #filters summary h2 { margin-left: -2px; }