Skip to content

Commit

Permalink
chore: 在每次展开面板的时候调整高亮
Browse files Browse the repository at this point in the history
  • Loading branch information
RSS1102 committed Oct 31, 2024
1 parent 16b08cc commit 05fb2e4
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/toolbars/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,7 @@ export default class Toolbar {
const btn = subMenu.createBtn(true);
// 二级菜单的dom认定为一级菜单的
subMenu.dom = subMenu.dom ? subMenu.dom : this.menus.hooks[name].dom;
btn.addEventListener(
'click',
(event) => {
this.onClick(event, level2Name, true);
this.activeSubMenuItem(name);
},
false,
);
btn.addEventListener('click', (event) => this.onClick(event, level2Name, true), false);
this.subMenus[name].appendChild(btn);
}
});
Expand All @@ -212,14 +205,7 @@ export default class Toolbar {
subMenuConfig.forEach((config) => {
const btn = this.menus.hooks[name].createSubBtnByConfig(config);
if (!config?.disabledHideAllSubMenu) {
btn.addEventListener(
'click',
() => {
this.hideAllSubMenu();
this.activeSubMenuItem(name);
},
false,
);
btn.addEventListener('click', () => this.hideAllSubMenu(), false);
}
this.subMenus[name].appendChild(btn);
});
Expand All @@ -238,10 +224,17 @@ export default class Toolbar {
if (this.isHasSubMenu(name) && !focusEvent) {
this.toggleSubMenu(name);
} else {
this.hideAllSubMenu();
// 如果是颜色选择器,则隐藏其他二级菜单,但不隐藏自己(因为颜色选择器的二级菜单是自己实现的独立逻辑)
if (name === 'color') {
// @ts-ignore
menu.hideOtherSubMenu(() => this.hideAllSubMenu());
} else {
this.hideAllSubMenu();
}
menu.fire(event, name);
}
}

/**
* 激活二级菜单添加选中颜色
* @param {string} name
Expand Down Expand Up @@ -271,6 +264,7 @@ export default class Toolbar {
this.hideAllSubMenu();
this.subMenus[name].style.display = 'block';
this.setSubMenuPosition(this.menus.hooks[name], this.subMenus[name]);
this.activeSubMenuItem(name);
} else {
// 如果是显示的,则隐藏当前二级菜单
this.subMenus[name].style.display = 'none';
Expand Down

0 comments on commit 05fb2e4

Please sign in to comment.