Skip to content

Commit d075e54

Browse files
authored
Fixed bug of editable control with focus by script (#202)
* Fixed bug of editable control with focus by script * update
1 parent a0119ca commit d075e54

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

packages/cheetah-grid/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cheetah-grid/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cheetah-grid",
3-
"version": "0.17.0",
3+
"version": "0.17.1",
44
"description": "Cheetah Grid is a high performance grid engine that works on canvas",
55
"keywords": [
66
"spreadsheet",

packages/cheetah-grid/src/js/core/DrawGrid.ts

+27-18
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,28 @@ function _moveFocusCell(
10481048
_invalidateRect(this, afterRect);
10491049
}
10501050
}
1051+
function _updatedSelection(this: DrawGrid): void {
1052+
const { focusControl } = this[_];
1053+
const { col: selCol, row: selRow } = this[_].selection.select;
1054+
const results = this.fireListeners(DG_EVENT_TYPE.EDITABLEINPUT_CELL, {
1055+
col: selCol,
1056+
row: selRow
1057+
});
1058+
1059+
const editMode = array.findIndex(results, v => !!v) >= 0;
1060+
focusControl.editMode = editMode;
1061+
1062+
if (editMode) {
1063+
focusControl.storeInputStatus();
1064+
focusControl.setDefaultInputStatus();
1065+
this.fireListeners(DG_EVENT_TYPE.MODIFY_STATUS_EDITABLEINPUT_CELL, {
1066+
col: selCol,
1067+
row: selRow,
1068+
input: focusControl.input
1069+
});
1070+
}
1071+
}
1072+
10511073
function _getMouseAbstractPoint(
10521074
grid: DrawGrid,
10531075
evt: TouchEvent | MouseEvent
@@ -2153,6 +2175,8 @@ class Selection extends EventTarget {
21532175
col: endCol,
21542176
row: endRow
21552177
};
2178+
2179+
_updatedSelection.call(this._grid);
21562180
});
21572181
}
21582182
get focus(): CellAddress {
@@ -2168,6 +2192,8 @@ class Selection extends EventTarget {
21682192
const { col = 0, row = 0 } = cell;
21692193
this._setSelectCell(col, row);
21702194
this._setFocusCell(col, row, true);
2195+
2196+
_updatedSelection.call(this._grid);
21712197
});
21722198
}
21732199
_setSelectCell(col: number, row: number): void {
@@ -3141,24 +3167,7 @@ export abstract class DrawGrid extends EventTarget implements DrawGridAPI {
31413167

31423168
focusControl.setFocusRect(this.getCellRect(col, row));
31433169

3144-
const { col: selCol, row: selRow } = this[_].selection.select;
3145-
const results = this.fireListeners(DG_EVENT_TYPE.EDITABLEINPUT_CELL, {
3146-
col: selCol,
3147-
row: selRow
3148-
});
3149-
3150-
const editMode = array.findIndex(results, v => !!v) >= 0;
3151-
focusControl.editMode = editMode;
3152-
3153-
if (editMode) {
3154-
focusControl.storeInputStatus();
3155-
focusControl.setDefaultInputStatus();
3156-
this.fireListeners(DG_EVENT_TYPE.MODIFY_STATUS_EDITABLEINPUT_CELL, {
3157-
col: selCol,
3158-
row: selRow,
3159-
input: focusControl.input
3160-
});
3161-
}
3170+
_updatedSelection.call(this);
31623171
}
31633172
/**
31643173
* Focus the cell.

packages/demo/package-lock.json

-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)