').appendTo('#qunit-fixture');
+ this.$element.trigger($.Event('focusout', {
+ target: this.$element.find('.dx-texteditor').get(0),
+ relatedTarget: $overlay.get(0),
+ }));
+ this.clock.tick(0);
+
+ assert.ok($(toolbar.option('focusedElement')).length > 0,
+ 'focusedElement is preserved when focus moves to overlay content');
+ $overlay.remove();
+ });
+
+ QUnit.test('Tab key is not intercepted by toolbar', function(assert) {
+ this.$element.dxToolbar({
+ items: [
+ { widget: 'dxButton', options: { text: 'A' } },
+ { widget: 'dxButton', options: { text: 'B' } },
+ ],
+ });
+
+ const $button = this.$element.find('.dx-button').first();
+ const event = new KeyboardEvent('keydown', {
+ key: 'Tab',
+ bubbles: true,
+ cancelable: true,
+ });
+ $button.get(0).dispatchEvent(event);
+
+ assert.strictEqual(event.defaultPrevented, false,
+ 'Tab keydown is not prevented by toolbar');
+ });
+
+ QUnit.test('allowKeyboardNavigation:true (default) — toolbar element has dx-toolbar-focus-mode class', function(assert) {
+ this.$element.dxToolbar({
+ items: [
+ { locateInMenu: 'never', widget: 'dxButton', options: { text: 'A' } },
+ ],
+ });
+
+ assert.ok(
+ this.$element.hasClass(TOOLBAR_FOCUS_MODE_CLASS),
+ 'toolbar has dx-toolbar-focus-mode class when allowKeyboardNavigation:true'
+ );
+ });
+
+ QUnit.test('allowKeyboardNavigation:false — toolbar element does NOT have dx-toolbar-focus-mode class', function(assert) {
+ this.$element.dxToolbar({
+ allowKeyboardNavigation: false,
+ items: [
+ { locateInMenu: 'never', widget: 'dxButton', options: { text: 'A' } },
+ ],
+ });
+
+ assert.notOk(
+ this.$element.hasClass(TOOLBAR_FOCUS_MODE_CLASS),
+ 'toolbar does not have dx-toolbar-focus-mode class when allowKeyboardNavigation:false'
+ );
+ });
+
+ QUnit.test('changing allowKeyboardNavigation at runtime toggles dx-toolbar-focus-mode class', function(assert) {
+ const toolbar = this.$element.dxToolbar({
+ allowKeyboardNavigation: true,
+ items: [
+ { locateInMenu: 'never', widget: 'dxButton', options: { text: 'A' } },
+ ],
+ }).dxToolbar('instance');
+
+ assert.ok(
+ this.$element.hasClass(TOOLBAR_FOCUS_MODE_CLASS),
+ 'class is present when allowKeyboardNavigation:true'
+ );
+
+ toolbar.option('allowKeyboardNavigation', false);
+
+ assert.notOk(
+ this.$element.hasClass(TOOLBAR_FOCUS_MODE_CLASS),
+ 'class is removed after setting allowKeyboardNavigation:false'
+ );
+
+ toolbar.option('allowKeyboardNavigation', true);
+
+ assert.ok(
+ this.$element.hasClass(TOOLBAR_FOCUS_MODE_CLASS),
+ 'class is re-added after setting allowKeyboardNavigation:true'
+ );
+ });
+
+ QUnit.test('allowKeyboardNavigation:true — overflow popup wrapper has dx-dropdownmenu-list-focus-mode class', function(assert) {
+ const toolbar = this.$element.dxToolbar({
+ allowKeyboardNavigation: true,
+ items: [
+ { widget: 'dxButton', locateInMenu: 'always', options: { text: 'Menu A' } },
+ ],
+ }).dxToolbar('instance');
+
+ const menu = toolbar._layoutStrategy._menu;
+ menu.option('opened', true);
+ this.clock.tick(0);
+
+ const $wrapper = $(`.${DROP_DOWN_MENU_POPUP_WRAPPER_CLASS}`);
+ assert.ok(
+ $wrapper.hasClass(DROPDOWNMENU_LIST_FOCUS_MODE_CLASS),
+ 'popup wrapper has dx-dropdownmenu-list-focus-mode class when allowKeyboardNavigation:true'
+ );
+ });
+
+ QUnit.test('allowKeyboardNavigation:false — overflow popup wrapper does NOT have dx-dropdownmenu-list-focus-mode class', function(assert) {
+ const toolbar = this.$element.dxToolbar({
+ allowKeyboardNavigation: false,
+ items: [
+ { widget: 'dxButton', locateInMenu: 'always', options: { text: 'Menu A' } },
+ ],
+ }).dxToolbar('instance');
+
+ const menu = toolbar._layoutStrategy._menu;
+ menu.option('opened', true);
+ this.clock.tick(0);
+
+ const $wrapper = $(`.${DROP_DOWN_MENU_POPUP_WRAPPER_CLASS}`);
+ assert.notOk(
+ $wrapper.hasClass(DROPDOWNMENU_LIST_FOCUS_MODE_CLASS),
+ 'popup wrapper does not have dx-dropdownmenu-list-focus-mode class when allowKeyboardNavigation:false'
+ );
+ });
+
+ QUnit.test('changing allowKeyboardNavigation at runtime toggles dx-dropdownmenu-list-focus-mode on popup wrapper', function(assert) {
+ const toolbar = this.$element.dxToolbar({
+ allowKeyboardNavigation: true,
+ items: [
+ { widget: 'dxButton', locateInMenu: 'always', options: { text: 'Menu A' } },
+ ],
+ }).dxToolbar('instance');
+
+ const menu = toolbar._layoutStrategy._menu;
+ menu.option('opened', true);
+ this.clock.tick(0);
+
+ const $wrapper = $(`.${DROP_DOWN_MENU_POPUP_WRAPPER_CLASS}`);
+
+ assert.ok(
+ $wrapper.hasClass(DROPDOWNMENU_LIST_FOCUS_MODE_CLASS),
+ 'popup wrapper has class when allowKeyboardNavigation:true'
+ );
+
+ toolbar.option('allowKeyboardNavigation', false);
+
+ assert.notOk(
+ $wrapper.hasClass(DROPDOWNMENU_LIST_FOCUS_MODE_CLASS),
+ 'popup wrapper loses class after setting allowKeyboardNavigation:false'
+ );
+
+ toolbar.option('allowKeyboardNavigation', true);
+
+ assert.ok(
+ $wrapper.hasClass(DROPDOWNMENU_LIST_FOCUS_MODE_CLASS),
+ 'popup wrapper regains class after setting allowKeyboardNavigation:true'
+ );
+ });
+});
+
+QUnit.module('Non-focusable service items', moduleConfig, function() {
+ QUnit.test('separator template is excluded from _getAvailableItems', function(assert) {
+ const toolbar = this.$element.dxToolbar({
+ items: [
+ { locateInMenu: 'never', widget: 'dxButton', options: { text: 'A' } },
+ { locateInMenu: 'never', template: () => $('