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 () {
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() {

View File

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