🚑 Fix section error in Firefox (#633)

This commit is contained in:
Alicia Sykes 2022-05-06 12:43:30 +01:00
parent af5a26b0da
commit 7165a9a913

View File

@ -177,18 +177,18 @@ export default {
}, },
/* If the sortBy attribute is specified, then return sorted data */ /* If the sortBy attribute is specified, then return sorted data */
sortedItems() { sortedItems() {
let { items } = this; const items = [...this.items];
if (this.appConfig.disableSmartSort) return items; if (this.appConfig.disableSmartSort) return items;
if (this.sortOrder === 'alphabetical') { if (this.sortOrder === 'alphabetical') {
this.sortAlphabetically(items); return this.sortAlphabetically(items);
} else if (this.sortOrder === 'reverse-alphabetical') { } else if (this.sortOrder === 'reverse-alphabetical') {
this.sortAlphabetically(items).reverse(); return this.sortAlphabetically(items).reverse();
} else if (this.sortOrder === 'most-used') { } else if (this.sortOrder === 'most-used') {
items = this.sortByMostUsed(items); return this.sortByMostUsed(items);
} else if (this.sortOrder === 'last-used') { } else if (this.sortOrder === 'last-used') {
items = this.sortByLastUsed(items); return this.sortByLastUsed(items);
} else if (this.sortOrder === 'random') { } else if (this.sortOrder === 'random') {
items = this.sortRandomly(items); return this.sortRandomly(items);
} else if (this.sortOrder && this.sortOrder !== 'default') { } else if (this.sortOrder && this.sortOrder !== 'default') {
ErrorHandler(`Unknown Sort order '${this.sortOrder}' under '${this.title}'`); ErrorHandler(`Unknown Sort order '${this.sortOrder}' under '${this.title}'`);
} }
@ -291,13 +291,15 @@ export default {
/* Calculate width of section, used to dynamically set number of columns */ /* Calculate width of section, used to dynamically set number of columns */
calculateSectionWidth() { calculateSectionWidth() {
const secElem = this.$refs[this.sectionRef]; const secElem = this.$refs[this.sectionRef];
if (secElem) this.sectionWidth = secElem.$el.clientWidth; if (secElem && secElem.$el.clientWidth) this.sectionWidth = secElem.$el.clientWidth;
}, },
}, },
mounted() { mounted() {
// Set the section width, and recalculate when section resized // Set the section width, and recalculate when section resized
this.resizeObserver = new ResizeObserver(this.calculateSectionWidth) if (this.$refs[this.sectionRef]) {
.observe(this.$refs[this.sectionRef].$el); this.resizeObserver = new ResizeObserver(this.calculateSectionWidth)
.observe(this.$refs[this.sectionRef].$el);
}
}, },
beforeDestroy() { beforeDestroy() {
// If resize observer set, and element still present, then de-register // If resize observer set, and element still present, then de-register