don't filter out invisible menu separators (#12825)

This commit is contained in:
Shelley Vohr 2018-05-04 07:59:40 -07:00 committed by GitHub
parent b280ea5579
commit f67c625e6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -240,14 +240,19 @@ function indexToInsertByPosition (items, position) {
}
function removeExtraSeparators (items) {
// remove invisible items
let ret = items.filter(e => e.visible !== false)
// fold adjacent separators together
ret = ret.filter((e, idx, arr) => e.type !== 'separator' || idx === 0 || arr[idx - 1].type !== 'separator')
let ret = items.filter((e, idx, arr) => {
if (e.visible === false) return true
return e.type !== 'separator' || idx === 0 || arr[idx - 1].type !== 'separator'
})
// remove edge separators
return ret.filter((e, idx, arr) => e.type !== 'separator' || (idx !== 0 && idx !== arr.length - 1))
ret = ret.filter((e, idx, arr) => {
if (e.visible === false) return true
return e.type !== 'separator' || (idx !== 0 && idx !== arr.length - 1)
})
return ret
}
function insertItemByType (item, pos) {