Skip to content

Conversation

@spike-rabbit
Copy link
Member

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)
The selected input is decorator based and preserves the original array when mutated.

What is the new behavior?
selected is a model and no longer mutates the array.

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

The selected input no longer mutates the original array passed to the component. Applications that rely on the array being updated in place must switch to two-way binding with [(selected)] to maintain reactivity.

Other information:
The DatatableComponent.select output is deprecated; use (selectedChange) or two-way binding instead .

Before:

<ngx-datatable [selected]="mySelection" (select)="onSelect($event)"></ngx-datatable>

After:

<ngx-datatable [(selected)]="mySelection" (selectedChange)="onSelect({selected: $event})"></ngx-datatable>
<!-- or -->
<ngx-datatable [(selected)]="mySelection"></ngx-datatable>

@spike-rabbit spike-rabbit requested a review from a team as a code owner November 3, 2025 18:57
@spike-rabbit spike-rabbit added the breaking-changes Marks issues and PRs that are breaking the API label Nov 3, 2025
@spike-rabbit spike-rabbit force-pushed the refactor/datatable/use-model-for-selected branch from e4bafc1 to 9cb50d3 Compare November 3, 2025 19:04
Convert the selected input to a signal model.

BREAKING CHANGE: The selected input no longer mutates the original array
passed to the component. Applications that rely on the array being updated
in place must switch to two-way binding with [(selected)] to maintain
reactivity.

DEPRECATED: The `DatatableComponent.select` output is deprecated; use (selectedChange)
or two-way binding instead .

Before:
```html
<ngx-datatable [selected]="mySelection" (select)="onSelect($event)"></ngx-datatable>
```

After:
```html
<ngx-datatable [(selected)]="mySelection" (selectedChange)="onSelect({selected: $event})"></ngx-datatable>
<!-- or -->
<ngx-datatable [(selected)]="mySelection"></ngx-datatable>
```
@spike-rabbit spike-rabbit force-pushed the refactor/datatable/use-model-for-selected branch from 9cb50d3 to 7ae8ca7 Compare November 3, 2025 19:13
@fh1ch fh1ch requested a review from Copilot November 3, 2025 20:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the datatable selection mechanism by migrating from an @Input() property to Angular's two-way binding model pattern. The selected property is now a signal-based model that supports two-way binding, and the SelectEvent interface and select output are deprecated in favor of using selectedChange with two-way binding.

  • Converted selected from @Input() to model<TRow[]>() signal in both datatable and body components
  • Updated all references to selected to use signal getter syntax selected()
  • Replaced array mutation operations with selected.set() calls
  • Deprecated the SelectEvent interface and select output in favor of two-way binding

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/app/selection/selection-single.component.ts Updated example app to use two-way binding syntax [(selected)] and (selectedChange) event instead of deprecated (select)
projects/ngx-datatable/src/lib/types/public.types.ts Added deprecation notice to SelectEvent interface
projects/ngx-datatable/src/lib/components/datatable.component.ts Converted selected to model signal, updated all usages to call selected() and selected.set(), added deprecation documentation to select output, removed array mutation in onBodySelect
projects/ngx-datatable/src/lib/components/datatable.component.html Moved selected binding from removed input to two-way binding on body component, updated selectedCount to use signal getter
Comments suppressed due to low confidence (1)

projects/ngx-datatable/src/lib/components/datatable.component.ts:480

  • Corrected spelling of 'controll' to 'control'.
   * A flag to controll behavior of sort states.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-changes Marks issues and PRs that are breaking the API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants