simplify adjustWidth and make it work in FF

This commit is contained in:
tophf 2020-11-17 22:47:14 +03:00
parent 8b98baba6a
commit ffeef695fa
2 changed files with 11 additions and 16 deletions

View File

@ -23,18 +23,17 @@ router.watch({search: ['search', 'searchMode']}, ([search, mode]) => {
}); });
HTMLSelectElement.prototype.adjustWidth = function () { HTMLSelectElement.prototype.adjustWidth = function () {
const option0 = this.selectedOptions[0]; const sel = this.selectedOptions[0];
if (!option0) return; if (!sel) return;
const parent = this.parentNode; const wOld = parseFloat(this.style.width);
const singleSelect = this.cloneNode(false); const opts = [...this];
singleSelect.style.width = ''; opts.forEach(opt => opt !== sel && opt.remove());
singleSelect.appendChild(option0.cloneNode(true)); this.style.width = '';
parent.replaceChild(singleSelect, this); requestAnimationFrame(() => {
const w = singleSelect.offsetWidth; const w = this.offsetWidth;
if (w && this.style.width !== w + 'px') { if (w && wOld !== w) this.style.width = w + 'px';
this.style.width = w + 'px'; this.append(...opts);
} });
parent.replaceChild(this, singleSelect);
}; };
function initFilters() { function initFilters() {

View File

@ -1200,10 +1200,6 @@ a:hover {
padding-left: 0; padding-left: 0;
} }
#reset-filters {
margin-top: 4px;
}
#filters summary h2 { #filters summary h2 {
margin-left: -2px; margin-left: -2px;
} }