Skip to content

Commit c32812e

Browse files
committed
refactor: deprecate positional navigateTo signature
Deprecate the positional `navigateTo(row, column?, activate?)` signature in favor of the new `navigateTo(row, options)` signature, instead of an outright breaking change.
1 parent 039365c commit c32812e

3 files changed

Lines changed: 37 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Keyboard navigation and click activation set DOM focus on the active cell. Screen readers announce the cell. [#79](https://github.com/IgniteUI/igniteui-grid-lite/pull/79)
1616
- Public `columns` setter. [#78](https://github.com/IgniteUI/igniteui-grid-lite/pull/78)
1717

18+
### Deprecated
19+
20+
- The positional `navigateTo(row, column?, activate?)` arguments. Use `navigateTo(row, options)` instead. [#79](https://github.com/IgniteUI/igniteui-grid-lite/pull/79)
21+
1822
### Changed
1923

20-
- **BREAKING:** `navigateTo(row, options)` replaces the positional `navigateTo(row, column?, activate?)` arguments. Navigation without a column keeps the current column. [#79](https://github.com/IgniteUI/igniteui-grid-lite/pull/79)
24+
- Navigation without a column keeps the current column. [#79](https://github.com/IgniteUI/igniteui-grid-lite/pull/79)
2125
- Cell activation updates only the two affected rows, not all visible rows. [#79](https://github.com/IgniteUI/igniteui-grid-lite/pull/79)
2226
- Faster rendering: rows reuse cells across column changes, sorting shares one collator, and a `ResizeObserver` drives the scrollbar offset. [#78](https://github.com/IgniteUI/igniteui-grid-lite/pull/78)
2327

src/components/grid.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,24 @@ export class IgcGridLite<T extends object = any> extends EventEmitterBase<IgcGri
492492
* @param row The row index to navigate to
493493
* @param options The column field to navigate to and whether to activate the cell
494494
*/
495-
public async navigateTo(row: number, options?: NavigateToOptions<T>) {
495+
public async navigateTo(row: number, options?: NavigateToOptions<T>): Promise<void>;
496+
/**
497+
* Navigates to a position in the grid based on provided row index and column field.
498+
* @param row The row index to navigate to
499+
* @param column The column field to navigate to, if any
500+
* @param activate Optionally also activate the navigated cell
501+
* @deprecated Use `navigateTo(row, options)` instead.
502+
*/
503+
public async navigateTo(row: number, column?: Keys<T>, activate?: boolean): Promise<void>;
504+
public async navigateTo(
505+
row: number,
506+
columnOrOptions?: Keys<T> | NavigateToOptions<T>,
507+
activate?: boolean
508+
): Promise<void> {
509+
// Normalize the deprecated positional form into options.
510+
const options =
511+
typeof columnOrOptions === 'object' ? columnOrOptions : { column: columnOrOptions, activate };
512+
496513
await this._stateController.navigation.navigateTo(row, options);
497514
}
498515

test/activation.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,5 +290,19 @@ describe('Grid activation', () => {
290290
expect(cell.active).to.be.true;
291291
expect(isVisibleGrid(cell.element)).to.be.true;
292292
});
293+
294+
it('supports the deprecated positional signature', async () => {
295+
await TDD.grid.navigateTo(1, 'name');
296+
297+
let cell = TDD.rows.get(1).cells.get('name');
298+
expect(cell.active).to.be.false;
299+
expect(isVisibleGrid(cell.element)).to.be.true;
300+
301+
await TDD.grid.navigateTo(2, 'id', true);
302+
303+
cell = TDD.rows.get(2).cells.get('id');
304+
expect(cell.active).to.be.true;
305+
expect(isVisibleGrid(cell.element)).to.be.true;
306+
});
293307
});
294308
});

0 commit comments

Comments
 (0)