Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(common): context menu should close when clicking another cell #1163

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ const treeDataServiceStub = {
} as unknown as TreeDataService;

describe('ContextMenu Plugin', () => {
const consoleWarnSpy = jest.spyOn(global.console, 'warn').mockReturnValue();
let backendUtilityService: BackendUtilityService;
let extensionUtility: ExtensionUtility;
let translateService: TranslateServiceStub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,8 @@ describe('GridMenuControl', () => {

describe('with I18N Service', () => {
const consoleErrorSpy = jest.spyOn(global.console, 'error').mockReturnValue();
const consoleWarnSpy = jest.spyOn(global.console, 'warn').mockReturnValue();
// let divElement;

beforeEach(() => {
// divElement = document.createElement('div');
div = document.createElement('div');
div.innerHTML = template;
document.body.appendChild(div);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const columnsMock: Column[] = [
];

describe('HeaderButton Plugin', () => {
const consoleWarnSpy = jest.spyOn(global.console, 'warn').mockReturnValue();
let backendUtilityService: BackendUtilityService;
let extensionUtility: ExtensionUtility;
let translateService: TranslateServiceStub;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/slickCellMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class SlickCellMenu extends MenuFromCellBaseClass<CellMenu> {
}

// Hide the menu on outside click.
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener);
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener, { capture: true });
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/slickColumnPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class SlickColumnPicker {
this._bindEventService.bind(this._menuElm, 'click', handleColumnPickerItemClick.bind(this) as EventListener, undefined, 'parent-menu');

// Hide the menu on outside click.
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener);
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener, { capture: true });

// destroy the picker if user leaves the page
this._bindEventService.bind(document.body, 'beforeunload', this.dispose.bind(this) as EventListener);
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/slickContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class SlickContextMenu extends MenuFromCellBaseClass<ContextMenu> {
}

// Hide the menu on outside click.
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener);
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener, { capture: true });
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/slickGridMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class SlickGridMenu extends MenuBaseClass<GridMenu> {
this.translateTitleLabels(this.sharedService.gridOptions.gridMenu);

// hide the menu on outside click.
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener);
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener, { capture: true });

// destroy the picker if user leaves the page
this._bindEventService.bind(document.body, 'beforeunload', this.dispose.bind(this) as EventListener);
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/extensions/slickHeaderMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class SlickHeaderMenu extends MenuBaseClass<HeaderMenu> {
this.grid.setColumns(this.grid.getColumns());

// hide the menu when clicking outside the grid
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener);
this._bindEventService.bind(document.body, 'mousedown', this.handleBodyMouseDown.bind(this) as EventListener, { capture: true });
}

/** Dispose (destroy) of the plugin */
Expand Down
3 changes: 3 additions & 0 deletions test/cypress/e2e/example12.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ describe('Example 12 - Composite Editor Modal', { retries: 1 }, () => {
// change Completed
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(7)`).click();
cy.get('.editor-completed').check();
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(7)`).find('.mdi.mdi-check.checkmark-icon').should('have.length', 1);

cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(7)`).click();
cy.get('.editor-completed').check();
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(7)`).find('.mdi.mdi-check.checkmark-icon').should('have.length', 1);

cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(7)`).click();
cy.get('.editor-completed').check();
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(7)`).find('.mdi.mdi-check.checkmark-icon').should('have.length', 1);
});

it('should be able to change "Finish" values of row indexes 0-2', () => {
Expand Down