From 754bc9c8bc16f9a787d84e3f9afdb2b299d38f11 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 20 Sep 2021 01:41:38 +0300 Subject: [PATCH] Fix menu focus in ComboDataView --- apps/common/main/lib/component/ComboDataView.js | 11 ++++++----- apps/common/main/lib/component/DataView.js | 2 +- apps/common/main/lib/component/Menu.js | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/component/ComboDataView.js b/apps/common/main/lib/component/ComboDataView.js index d3a1f3bd0..fb0b1af65 100644 --- a/apps/common/main/lib/component/ComboDataView.js +++ b/apps/common/main/lib/component/ComboDataView.js @@ -114,20 +114,17 @@ define([ offset: [0, 3], items: [ {template: _.template('')} - ] + ].concat(this.options.additionalMenuItems != null ? this.options.additionalMenuItems : []) }), dataHint: this.options.dataHint, dataHintDirection: this.options.dataHintDirection, dataHintOffset: this.options.dataHintOffset }); - if (this.options.additionalMenuItems != null) { - this.openButton.menu.items = this.openButton.menu.items.concat(this.options.additionalMenuItems) - } - this.menuPicker = new Common.UI.DataView({ cls: 'menu-picker', parentMenu: this.openButton.menu, + outerMenu: this.options.additionalMenuItems ? {menu: this.openButton.menu, index: 0} : undefined, restoreHeight: this.menuMaxHeight, style: 'max-height: '+this.menuMaxHeight+'px;', enableKeyEvents: this.options.enableKeyEvents, @@ -143,6 +140,10 @@ define([ delayRenderTips: this.delayRenderTips }); + if (this.options.additionalMenuItems != null) { + this.openButton.menu.setInnerMenu([{menu: this.menuPicker, index: 0}]); + } + // Handle resize setInterval(_.bind(this.checkSize, this), 500); diff --git a/apps/common/main/lib/component/DataView.js b/apps/common/main/lib/component/DataView.js index 17a7888ea..e09b8f9d3 100644 --- a/apps/common/main/lib/component/DataView.js +++ b/apps/common/main/lib/component/DataView.js @@ -830,7 +830,7 @@ define([ }, focus: function(index) { - this.cmpEl && this.cmpEl.find('.dataview').focus(); + $(this.el).find('.inner').addBack().filter('.inner').focus(); if (typeof index == 'string') { if (index == 'first') { this.selectByIndex(0, true); diff --git a/apps/common/main/lib/component/Menu.js b/apps/common/main/lib/component/Menu.js index 673e66b2f..d8c410063 100644 --- a/apps/common/main/lib/component/Menu.js +++ b/apps/common/main/lib/component/Menu.js @@ -536,7 +536,7 @@ define([ if (this.options.innerMenus || !menus) return; this.options.innerMenus = menus; - this.options.innerMenus && this.on('keydown:before', _.bind(this.onBeforeKeyDown, this)); + this.rendered && this.on('keydown:before', _.bind(this.onBeforeKeyDown, this)); }, findInnerMenu: function(direction, index, findOuter) {