Skip to content

Commit 8a8d3f4

Browse files
authored
fix: remove "active" CSS classes before navigating to another cell (#1095)
* fix: remove "active" CSS classes before navigating to another cell
1 parent 3b1ef46 commit 8a8d3f4

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/slick.grid.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5860,11 +5860,20 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
58605860
//////////////////////////////////////////////////////////////////////////////////////////////
58615861
// Cell switching
58625862

5863-
/** Resets active cell. */
5863+
/** Resets active cell by making cell normal and other internal resets. */
58645864
resetActiveCell() {
58655865
this.setActiveCellInternal(null, false);
58665866
}
58675867

5868+
/** Clear active cell by making cell normal & removing "active" CSS class. */
5869+
unsetActiveCell() {
5870+
if (Utils.isDefined(this.activeCellNode)) {
5871+
this.makeActiveCellNormal();
5872+
this.activeCellNode.classList.remove('active');
5873+
this.rowsCache[this.activeRow]?.rowNode?.forEach((node) => node.classList.remove('active'));
5874+
}
5875+
}
5876+
58685877
/** @alias `setFocus` */
58695878
focus() {
58705879
this.setFocus();
@@ -5913,11 +5922,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
59135922
}
59145923

59155924
protected setActiveCellInternal(newCell: HTMLDivElement | null, opt_editMode?: boolean | null, preClickModeOn?: boolean | null, suppressActiveCellChangedEvent?: boolean, e?: Event | SlickEvent_) {
5916-
if (Utils.isDefined(this.activeCellNode)) {
5917-
this.makeActiveCellNormal();
5918-
this.activeCellNode.classList.remove('active');
5919-
this.rowsCache[this.activeRow]?.rowNode?.forEach((node) => node.classList.remove('active'));
5920-
}
5925+
// make current active cell as normal cell & remove "active" CSS classes
5926+
this.unsetActiveCell();
59215927

59225928
// let activeCellChanged = (this.activeCellNode !== newCell);
59235929
this.activeCellNode = newCell;
@@ -6350,11 +6356,13 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
63506356

63516357
/** Navigate to the top of the grid */
63526358
navigateTop() {
6359+
this.unsetActiveCell();
63536360
this.navigateToRow(0);
63546361
}
63556362

63566363
/** Navigate to the bottom of the grid */
63576364
navigateBottom() {
6365+
this.unsetActiveCell();
63586366
this.navigateToRow(this.getDataLength() - 1);
63596367
}
63606368

@@ -6689,6 +6697,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
66896697
return true;
66906698
}
66916699
this.setFocus();
6700+
this.unsetActiveCell();
66926701

66936702
const tabbingDirections = {
66946703
'up': -1,

0 commit comments

Comments
 (0)