Skip to content

Commit

Permalink
revert(menu)
Browse files Browse the repository at this point in the history
  • Loading branch information
marker dao ® committed Oct 2, 2024
1 parent 978d27b commit 9d988b4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,18 @@ class ContextMenu extends MenuBase {
return !isInsideContextMenu;
}

_hideOnFocusOut(): void {
this.hide();
_focusOutHandler(e): void {
const { relatedTarget } = e;

if (relatedTarget) {
const isTargetOutside = this._isTargetOutOfComponent(relatedTarget);

if (isTargetOutside) {
this.hide();
}
}

super._focusOutHandler(e);
}

_renderContentImpl(): void {
Expand Down
20 changes: 1 addition & 19 deletions packages/devextreme/js/__internal/ui/context_menu/m_menu_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const ITEM_URL_CLASS = 'dx-item-url';

export type Properties = dxMenuBaseOptions<MenuBase, Item>;

abstract class MenuBase extends HierarchicalCollectionWidget<Properties> {
class MenuBase extends HierarchicalCollectionWidget<Properties> {
static ItemClass = MenuItem;

_editStrategy?: MenuBaseEditStrategy;
Expand All @@ -54,10 +54,6 @@ abstract class MenuBase extends HierarchicalCollectionWidget<Properties> {

_showSubmenusTimeout?: any;

abstract _isTargetOutOfComponent(target: Element): boolean;

abstract _hideOnFocusOut(): void;

_getDefaultOptions() {
return extend(super._getDefaultOptions(), {
items: [],
Expand Down Expand Up @@ -224,20 +220,6 @@ abstract class MenuBase extends HierarchicalCollectionWidget<Properties> {
};
}

_focusOutHandler(e) {
const { relatedTarget } = e;

if (relatedTarget) {
const isTargetOutside = this._isTargetOutOfComponent(relatedTarget);

if (isTargetOutside) {
this._hideOnFocusOut();
}
}

super._focusOutHandler(e);
}

_selectByItem(selectedItem): void {
if (!selectedItem) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,6 @@ const DropDownEditor = TextBox.inherit({
this._createPopup();
}

// debugger;

this.$element().toggleClass(DROP_DOWN_EDITOR_ACTIVE, opened);
this._setPopupOption('visible', opened);

Expand Down
16 changes: 13 additions & 3 deletions packages/devextreme/js/__internal/ui/menu/m_menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class Menu extends MenuBase {
this._initAdaptivity();
}

_isTargetOutOfComponent(relatedTarget: Element): boolean {
_isTargetOutOfComponent(relatedTarget): boolean {
const isInsideRootMenu = $(relatedTarget).closest(`.${DX_MENU_CLASS}`).length !== 0;
const isInsideContextMenu = $(relatedTarget).closest(`.${DX_CONTEXT_MENU_CLASS}`).length !== 0;

Expand All @@ -297,8 +297,18 @@ class Menu extends MenuBase {
return isTargetOutOfComponent;
}

_hideOnFocusOut(): void {
this._hideVisibleSubmenu();
_focusOutHandler(e) {
const { relatedTarget } = e;

if (relatedTarget) {
const isTargetOutside = this._isTargetOutOfComponent(relatedTarget);

if (isTargetOutside) {
this._hideVisibleSubmenu();
}
}

super._focusOutHandler(e);
}

_renderHamburgerButton(): Element {
Expand Down

0 comments on commit 9d988b4

Please sign in to comment.