mirror of
https://github.com/element-plus/element-plus.git
synced 2025-04-06 16:30:35 +08:00
fix(components): [menu] fix sliceIndex
calculation error (#19164)
fix(components): [menu] Fix 'sliceIndex' calculation error closed #19161
This commit is contained in:
parent
83cda2115a
commit
8b829ea7d3
@ -326,10 +326,7 @@ export default defineComponent({
|
||||
const calcSliceIndex = () => {
|
||||
if (!menu.value) return -1
|
||||
const items = Array.from(menu.value?.childNodes ?? []).filter(
|
||||
(item) =>
|
||||
// remove comment type node #12634
|
||||
item.nodeName !== '#comment' &&
|
||||
(item.nodeName !== '#text' || item.nodeValue)
|
||||
(item) => item.nodeName !== '#text' || item.nodeValue
|
||||
) as HTMLElement[]
|
||||
const moreItemWidth = 64
|
||||
const computedMenuStyle = getComputedStyle(menu.value!)
|
||||
@ -339,6 +336,7 @@ export default defineComponent({
|
||||
let calcWidth = 0
|
||||
let sliceIndex = 0
|
||||
items.forEach((item, index) => {
|
||||
if (item.nodeName === '#comment') return
|
||||
calcWidth += calcMenuItemWidth(item)
|
||||
if (calcWidth <= menuWidth - moreItemWidth) {
|
||||
sliceIndex = index + 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user