如何修复Chrome 43中的子菜单消失?
使用Extjs 4.
这适用于以前版本的Chrome。
答案 0 :(得分:9)
需要添加此覆盖才能解决此问题。
https://www.sencha.com/forum/showthread.php?301116-Submenus-disappear-in-Chrome-43-beta
(感谢Sencha论坛上的festr用户 - 认为这也需要在SO上)
// fix hide submenu (in chrome 43)
Ext.override(Ext.menu.Menu, {
onMouseLeave: function(e) {
var me = this;
// BEGIN FIX
var visibleSubmenu = false;
me.items.each(function(item) {
if(item.menu && item.menu.isVisible()) {
visibleSubmenu = true;
}
})
if(visibleSubmenu) {
//console.log('apply fix hide submenu');
return;
}
// END FIX
me.deactivateActiveItem();
if (me.disabled) {
return;
}
me.fireEvent('mouseleave', me, e);
}
});
答案 1 :(得分:0)
关于同一个链接,https://www.sencha.com/forum/showthread.php?301116-Submenus-disappear-in-Chrome-43-beta,这是一个更通用,非特定的解决方法,感谢siq发布的第27条:
Ext.apply(Ext.EventManager,{
normalizeEvent: function(eventName, fn) {
//start fix
var EventManager = Ext.EventManager,
supports = Ext.supports;
if(Ext.chromeVersion >=43 && eventName == 'mouseover'){
var origFn = fn;
fn = function(){
var me = this,
args = arguments;
setTimeout(
function(){
origFn.apply(me || Ext.global, args);
},
0);
};
}
//end fix
if (EventManager.mouseEnterLeaveRe.test(eventName) && !supports.MouseEnterLeave) {
if (fn) {
fn = Ext.Function.createInterceptor(fn, EventManager.contains);
}
eventName = eventName == 'mouseenter' ? 'mouseover' : 'mouseout';
} else if (eventName == 'mousewheel' && !supports.MouseWheel && !Ext.isOpera) {
eventName = 'DOMMouseScroll';
}
return {
eventName: eventName,
fn: fn
};
}
});
这已经在我的测试中进行了测试,我可以验证它是否有效(v.4.1.2)。