Closed Guria closed 9 years ago
@Guria I can't reproduce this problem. There are no two bindings to _onKeyDown
. The handler on L34 is bound only in case of hasMod('focused')
, the handler on L42 is bound when focused
mod is being set. As far as I see they are bound in mutually exclusive cases.
Ok, i'll try to prepare a demo.
Here is bemjson to reproduce
({
block : 'page',
head : [
{ elem : 'css', url : '_menu-bug.css' },
{ elem : 'js', url : '_menu-bug.js' }
],
content : [
{ block : 'input' },
{
block : 'menu',
mods : { theme : 'islands', size : 'm' },
content : [
{
block : 'menu-item',
content : '1'
},
{
block : 'menu-item',
content : '2'
},
{
block : 'menu-item',
content : '3'
},
{
block : 'menu-item',
content : '4'
}
]
}
]
})
Press Tab twice, then arrow keys. You shouldn't hover a menu with mouse. In case of menu inited by setting focus from keyboard both handlers would be run: _focused_true handler then _js_inited which will cound second _onKeyDown handler .
@Guria I've caught the problem.
PR #1383
https://github.com/bem/bem-components/blob/v2/common.blocks/menu/menu.js#L34 https://github.com/bem/bem-components/blob/v2/common.blocks/menu/menu.js#L42 If
menu
block inited with tab focus_onKeyDown
handler bound twice. It causes scrolling two items with one cursor keypress.