Skip to content

Commit 73f5fd7

Browse files
committed
fix(MenuBar): display as much entries as iconsLimit allows
So far, we got all entries with priority smaller or equals to `iconsLimit`. Since entries can be conditional (emoji picker, assistant), this led to less entries in `visiblEntries` than wanted. Since we still want to keep the order of entries from `entries.js` we cannot just sort them by priority and need this slightly more complex filter logic. Signed-off-by: Jonas <jonas@freesources.org>
1 parent 92d0806 commit 73f5fd7

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/components/Menu/MenuBar.vue

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,23 @@ export default {
141141
}
142142
},
143143
computed: {
144+
visibleEntryKeys() {
145+
// if entry has no priority, we assume it always will be visible (priority: 0)
146+
return this.entries
147+
.toSorted((a, b) => (a.priority ?? 0) - (b.priority ?? 0))
148+
.map(e => e.key)
149+
.slice(0, this.iconsLimit)
150+
},
144151
visibleEntries() {
145-
const list = this.entries.filter(({ priority }) => {
146-
// if entry has no priority, we assume it always will be visible
147-
return priority === undefined || priority <= this.iconsLimit
152+
// only entries from `visibleEntryKeys but in original order
153+
return this.entries.filter((entry) => {
154+
return this.visibleEntryKeys.includes(entry.key)
148155
})
149-
150-
return list
151156
},
152157
hiddenEntries() {
153-
const remainingEntries = this.entries.filter(({ priority }) => {
158+
const remainingEntries = this.entries.filter((entry) => {
154159
// reverse logic from visibleEntries
155-
return priority !== undefined && priority > this.iconsLimit
160+
return !this.visibleEntryKeys.includes(entry.key)
156161
})
157162
const entries = remainingEntries.reduce((acc, entry, index) => {
158163
// If entry has children, merge them into list. Otherwise keep entry itself.

0 commit comments

Comments
 (0)