Skip to content

Commit 96ede2f

Browse files
GaoNeng-wWwkagol
authored andcommitted
fix(menu): 修复组件闪烁问题
1 parent a12e490 commit 96ede2f

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/devui-vue/devui/menu/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export { Menu, SubMenu, MenuItem };
88
export default {
99
title: 'Menu 菜单',
1010
category: '布局',
11-
status: '80%',
11+
status: '100%',
1212
install(app: App): void {
1313
app.component(Menu.name, Menu);
1414
app.component(MenuItem.name, MenuItem);

packages/devui-vue/devui/menu/src/menu.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@ export default defineComponent({
4040
const root = menuRoot.value as unknown as HTMLElement;
4141
const children = root.children;
4242
const container = overflowContainer.children[1];
43-
let preItem: HTMLElement | null;
4443
const ob = new IntersectionObserver(
4544
(entries: IntersectionObserverEntry[]) => {
4645
entries.forEach((v: IntersectionObserverEntry) => {
4746
if (!v.isIntersecting) {
4847
const cloneNode = v.target.cloneNode(true) as Element as HTMLElement;
49-
preItem = v.target as Element as HTMLElement;
5048
if (v.target.classList.contains(`${ns.b()}-overflow-container`)){
51-
if (flag && v.target.previousElementSibling){
49+
if (flag && v.target.previousElementSibling && container.children.length){
5250
root.appendChild(v.target.previousElementSibling);
5351
} else {flag = true;}
5452
} else {
@@ -66,10 +64,11 @@ export default defineComponent({
6664
!v.target.classList.contains(`${ns.b()}-overflow-container`) &&
6765
(v.target as HTMLElement).style.visibility === 'hidden'
6866
) {
69-
console.log(v.target, preItem, v.target === preItem);
7067
ob.unobserve(v.target);
71-
const el = container.children[container.children.length - 1];
72-
root.insertBefore(el, overflowContainer);
68+
const el = container.lastChild;
69+
if (el){
70+
root.insertBefore(el, overflowContainer);
71+
}
7372
const obItem = overflowContainer.previousElementSibling;
7473
if (obItem) {
7574
ob.observe(obItem);
@@ -78,7 +77,6 @@ export default defineComponent({
7877
const sub = obItem;
7978
const wrapper = obItem.children[1] as HTMLElement;
8079
(sub as HTMLElement).addEventListener('mouseenter', (ev: MouseEvent) => {
81-
console.log('emit');
8280
ev.stopPropagation();
8381
useShowSubMenu('mouseenter', ev, wrapper);
8482
});

0 commit comments

Comments
 (0)