-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new
beforeBeginEditing
hook (#10699)
- Loading branch information
Showing
12 changed files
with
460 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"issuesOrigin": "private", | ||
"title": "Added new `beforeBeginEditing` hook", | ||
"type": "added", | ||
"issueOrPR": 10699, | ||
"breaking": false, | ||
"framework": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
handsontable/src/__tests__/editorManager/openEditor.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
describe('EditorManager open editor', () => { | ||
const id = 'testContainer'; | ||
|
||
beforeEach(function() { | ||
this.$container = $(`<div id="${id}" style="width: 300px; height: 200px; overflow: auto"></div>`).appendTo('body'); | ||
}); | ||
|
||
afterEach(function() { | ||
if (this.$container) { | ||
destroy(); | ||
this.$container.remove(); | ||
} | ||
}); | ||
|
||
it('should be possible to open an editor using a mouse', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
}); | ||
selectCell(2, 2); | ||
mouseDoubleClick(getCell(2, 2)); | ||
|
||
expect(isEditorVisible()).toBe(true); | ||
expect(getActiveEditor()).toBeDefined(); | ||
}); | ||
|
||
it('should not be possible to open an editor using a mouse when more than 2 cells are selected (while holding Shift)', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
}); | ||
selectCell(2, 2, 2, 3); | ||
keyDown('shift'); | ||
mouseDoubleClick(getCell(2, 3)); | ||
|
||
expect(isEditorVisible()).toBe(false); | ||
expect(getActiveEditor()).toBeUndefined(); | ||
}); | ||
|
||
it('should be possible to open an editor using a mouse when 1 cell is selected (while holding Shift)', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
}); | ||
selectCell(2, 2); | ||
keyDown('shift'); | ||
mouseDoubleClick(getCell(2, 2)); | ||
|
||
expect(isEditorVisible()).toBe(true); | ||
expect(getActiveEditor()).toBeDefined(); | ||
}); | ||
|
||
it('should not be possible to open an editor using a mouse when Ctrl/Cmd key is pressed', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
}); | ||
selectCell(2, 3); | ||
keyDown('control/meta'); | ||
mouseDoubleClick(getCell(2, 3)); | ||
|
||
expect(isEditorVisible()).toBe(false); | ||
expect(getActiveEditor()).toBeUndefined(); | ||
}); | ||
|
||
it('should be possible to open an editor using Enter key', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
}); | ||
selectCell(2, 2); | ||
keyDown('enter'); | ||
|
||
expect(isEditorVisible()).toBe(true); | ||
expect(getActiveEditor()).toBeDefined(); | ||
}); | ||
|
||
it('should be possible to open an editor using Enter key when more than 2 cells are selected (while holding Shift)', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
}); | ||
selectCell(2, 2, 2, 3); | ||
keyDownUp(['shift', 'enter']); | ||
|
||
expect(isEditorVisible()).toBe(true); | ||
expect(getActiveEditor()).toBeDefined(); | ||
expect(getActiveEditor().row).toBe(2); | ||
expect(getActiveEditor().col).toBe(2); | ||
}); | ||
|
||
it('should not be possible to open an editor using Enter key when Ctrl/Cmd key is pressed', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
}); | ||
selectCells([[1, 1], [2, 3]]); | ||
keyDownUp(['control/meta', 'enter']); | ||
|
||
expect(isEditorVisible()).toBe(false); | ||
expect(getActiveEditor()).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
handsontable/src/plugins/mergeCells/__tests__/openEditor.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
describe('MergeCells open editor', () => { | ||
const id = 'testContainer'; | ||
|
||
beforeEach(function() { | ||
this.$container = $(`<div id="${id}" style="width: 300px; height: 200px; overflow: auto"></div>`).appendTo('body'); | ||
}); | ||
|
||
afterEach(function() { | ||
if (this.$container) { | ||
destroy(); | ||
this.$container.remove(); | ||
} | ||
}); | ||
|
||
it('should be possible to open an editor using a mouse when merge cell is selected', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
mergeCells: [ | ||
{ row: 1, col: 1, rowspan: 2, colspan: 2 } | ||
] | ||
}); | ||
selectCell(1, 1); | ||
mouseDoubleClick(getCell(1, 1)); | ||
|
||
expect(isEditorVisible()).toBe(true); | ||
expect(getActiveEditor()).toBeDefined(); | ||
}); | ||
|
||
it('should be possible to open an editor using a mouse when merge cell is selected (while holding Shift)', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
mergeCells: [ | ||
{ row: 1, col: 1, rowspan: 2, colspan: 2 } | ||
] | ||
}); | ||
selectCell(1, 1); | ||
keyDown('shift'); | ||
mouseDoubleClick(getCell(1, 1)); | ||
|
||
expect(isEditorVisible()).toBe(true); | ||
expect(getActiveEditor()).toBeDefined(); | ||
}); | ||
|
||
it('should not be possible to open an editor using a mouse when more than 2 cells are selected (while holding Shift)', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
mergeCells: [ | ||
{ row: 1, col: 1, rowspan: 2, colspan: 2 } | ||
] | ||
}); | ||
selectCell(1, 1, 2, 3); | ||
keyDown('shift'); | ||
mouseDoubleClick(getCell(2, 3)); | ||
|
||
expect(isEditorVisible()).toBe(false); | ||
expect(getActiveEditor()).toBeUndefined(); | ||
}); | ||
|
||
it('should not be possible to open an editor using a mouse when Ctrl/Cmd key is pressed', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
mergeCells: [ | ||
{ row: 1, col: 1, rowspan: 2, colspan: 2 } | ||
] | ||
}); | ||
selectCell(1, 1); | ||
keyDown('control/meta'); | ||
mouseDoubleClick(getCell(1, 1)); | ||
|
||
expect(isEditorVisible()).toBe(false); | ||
expect(getActiveEditor()).toBeUndefined(); | ||
}); | ||
|
||
it('should be possible to open an editor for merged cell using Enter key', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
mergeCells: [ | ||
{ row: 1, col: 1, rowspan: 2, colspan: 2 } | ||
] | ||
}); | ||
selectCell(1, 1); | ||
keyDown('enter'); | ||
|
||
expect(isEditorVisible()).toBe(true); | ||
expect(getActiveEditor()).toBeDefined(); | ||
}); | ||
|
||
it('should be possible to open an editor for merged cell using Enter (while holding Shift)', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
mergeCells: [ | ||
{ row: 1, col: 1, rowspan: 2, colspan: 2 } | ||
] | ||
}); | ||
selectCell(1, 1); | ||
keyDownUp(['shift', 'enter']); | ||
|
||
expect(isEditorVisible()).toBe(true); | ||
expect(getActiveEditor()).toBeDefined(); | ||
expect(getActiveEditor().row).toBe(1); | ||
expect(getActiveEditor().col).toBe(1); | ||
}); | ||
|
||
it('should not be possible to open an editor using Enter key when Ctrl/Cmd key is pressed', () => { | ||
handsontable({ | ||
data: createSpreadsheetData(5, 5), | ||
mergeCells: [ | ||
{ row: 1, col: 1, rowspan: 2, colspan: 2 } | ||
] | ||
}); | ||
selectCells([[1, 1], [3, 4]]); | ||
keyDownUp(['control/meta', 'enter']); | ||
|
||
expect(isEditorVisible()).toBe(false); | ||
expect(getActiveEditor()).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.