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: remove "active" CSS classes before navigating to another cell #1095

Merged
merged 4 commits into from
Jan 11, 2025
Merged
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
21 changes: 15 additions & 6 deletions src/slick.grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5860,11 +5860,20 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
//////////////////////////////////////////////////////////////////////////////////////////////
// Cell switching

/** Resets active cell. */
/** Resets active cell by making cell normal and other internal resets. */
resetActiveCell() {
this.setActiveCellInternal(null, false);
}

/** Clear active cell by making cell normal & removing "active" CSS class. */
unsetActiveCell() {
if (Utils.isDefined(this.activeCellNode)) {
this.makeActiveCellNormal();
this.activeCellNode.classList.remove('active');
this.rowsCache[this.activeRow]?.rowNode?.forEach((node) => node.classList.remove('active'));
}
}

/** @alias `setFocus` */
focus() {
this.setFocus();
Expand Down Expand Up @@ -5913,11 +5922,8 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
}

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

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

/** Navigate to the top of the grid */
navigateTop() {
this.unsetActiveCell();
this.navigateToRow(0);
}

/** Navigate to the bottom of the grid */
navigateBottom() {
this.unsetActiveCell();
this.navigateToRow(this.getDataLength() - 1);
}

Expand Down Expand Up @@ -6689,6 +6697,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
return true;
}
this.setFocus();
this.unsetActiveCell();

const tabbingDirections = {
'up': -1,
Expand Down
Loading