Skip to content

Commit

Permalink
fix(gridMenu): remove GridMenu from DOM after closing it (#1169)
Browse files Browse the repository at this point in the history
* fix(gridMenu): remove GridMenu from DOM after closing it
  • Loading branch information
ghiscoding authored Nov 1, 2023
1 parent bc02092 commit 87b242f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ describe('GridMenuControl', () => {
expect(control.menuElement).toBeFalsy();
expect(pubSubSpy).toHaveBeenCalledWith('onGridMenuBeforeMenuShow', {
grid: gridStub,
menu: undefined,
menu: null,
allColumns: columnsMock,
columns: columnsMock,
visibleColumns: columnsMock
Expand Down Expand Up @@ -589,7 +589,7 @@ describe('GridMenuControl', () => {
expect(control.menuElement).toBeFalsy();
expect(pubSubSpy).toHaveBeenCalledWith('onGridMenuAfterMenuShow', {
grid: gridStub,
menu: undefined,
menu: null,
allColumns: columnsMock,
columns: columnsMock,
visibleColumns: columnsMock
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/extensions/slickGridMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export class SlickGridMenu extends MenuBaseClass<GridMenu> {
deleteMenu() {
this._bindEventService.unbindAll();
this._menuElm?.remove();
this._menuElm = null;
this._gridMenuButtonElm?.remove();
if (this._headerElm) {
// put back grid header original width (fixes width and frozen+gridMenu on left header)
Expand Down Expand Up @@ -440,6 +441,7 @@ export class SlickGridMenu extends MenuBaseClass<GridMenu> {

// empty the entire menu so that it's recreated every time it opens
emptyElement(this._menuElm);
this._menuElm?.remove();

if (this._addonOptions) {
const callbackArgs = {
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/example20.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('Example 20 - Basic grid inside a Shadow DOM', { retries: 0 }, () => {
describe('Example 20 - Basic grid inside a Shadow DOM', { retries: 1 }, () => {
const fullTitles = ['Title', 'Duration (days)', '% Complete', 'Start', 'Finish', 'Effort Driven'];

it('should display Example title', () => {
Expand Down

0 comments on commit 87b242f

Please sign in to comment.