Skip to content

Commit

Permalink
fix(overlay-menu): interactiveElements list is not reset in some scen…
Browse files Browse the repository at this point in the history
…arios

fix(overlay-menu): cannot select items on nested menus
  • Loading branch information
goremikins committed Oct 14, 2021
1 parent d1da5b6 commit 6e17cce
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/elements/src/overlay-menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import '../icon';
import '../item';
import { Item, ItemData } from '../item';
import { Overlay, OverlayPosition, OverlayPositionTarget } from '../overlay';
import { applyLock } from '../overlay/managers/interaction-lock-manager.js';

import { getId } from './helpers/uuid';
import { OverlayMenuData } from './helpers/types';
Expand Down Expand Up @@ -433,8 +434,17 @@ export class OverlayMenu extends Overlay {
});

this.setItemHighlight();
this.restoreNestedProperties();

if (OpenedMenusManager.isNested(this)) {
super.onClosed();
}

/**
* Restore properties back to original before bounding to parent menu
* @returns {void}
*/
private restoreNestedProperties (): void {
if (this.nested) {
this.nested = false;
this.position = this.oldPosition;
this.positionTarget = this.oldPositionTarget;
Expand Down Expand Up @@ -473,6 +483,7 @@ export class OverlayMenu extends Overlay {
private opening (): void {
const parentMenuItem = OpenedMenusManager.getParentMenuItem(this);
this.dataDisconnectThrottler.cancel();
this.restoreNestedProperties();

if (parentMenuItem) {
this.nested = true;
Expand All @@ -495,6 +506,11 @@ export class OverlayMenu extends Overlay {
this.positionTarget = parentMenu?.positionTarget;
this.position = parentMenu?.position;
}

// Managers are applied in shouldUpdate lifecycles (as not every property causes re-render)
// The process must follow certain order (which is better not to touch)
// `applyLock` fixes a problem when changes in properties above where not take into account
applyLock();
}
this.registerMenu();
}
Expand Down

0 comments on commit 6e17cce

Please sign in to comment.