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

Update selection changing events #13619

Merged
merged 20 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
325d26b
feat(combos): update selection changing events
wnvko Oct 31, 2023
18d01dc
test(combos): fix failing tests
wnvko Oct 31, 2023
9d80211
Merge branch 'master' into mvenkov/combo-selection-change-event-update
wnvko Oct 31, 2023
e42d1a1
test(simple-combo): fix failing tests
wnvko Oct 31, 2023
8308027
chore(combo): clean up combo common
wnvko Oct 31, 2023
edfd980
feat(combo): emit added and removed as full object
wnvko Nov 2, 2023
be96bdf
feat(combos): add migration for changed properties
wnvko Nov 2, 2023
15b166a
Merge remote-tracking branch 'remotes/origin/master' into mvenkov/com…
wnvko Nov 6, 2023
d24b3eb
Merge branch 'master' into mvenkov/combo-selection-change-event-update
Lipata Nov 6, 2023
7ae525e
Update CHANGELOG.md
wnvko Nov 6, 2023
3c2f976
Update CHANGELOG.md
wnvko Nov 6, 2023
4a3c77a
Update CHANGELOG.md
wnvko Nov 6, 2023
fe8f2a6
test(combo): add test for emitting partial data
wnvko Nov 6, 2023
d13c38c
Merge branch 'master' into mvenkov/combo-selection-change-event-update
Lipata Nov 6, 2023
cf36da5
test(combo): address PR comments
wnvko Nov 6, 2023
b934585
Merge branch 'mvenkov/combo-selection-change-event-update' of https:/…
wnvko Nov 6, 2023
f9d94b5
Merge remote-tracking branch 'remotes/origin/master' into mvenkov/com…
wnvko Nov 7, 2023
7195347
Merge branch 'master' into mvenkov/combo-selection-change-event-update
Lipata Nov 7, 2023
9e745f6
test(simple-combo): fix failing tests
wnvko Nov 7, 2023
0daddfb
test(simple-combo): fix more reactive form related tests
wnvko Nov 7, 2023
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ All notable changes for each version of this project will be documented in this
- We're working on reducing the library size
- IgxRadioComponent has been reduced in half
- IgxSwitchComponent has been reduced in half
- `IgxCombo`
- **Breaking Change** `IComboSelectionChangingEventArgs` properties `newSelection` and `oldSelection` have been renamed to `newValue` and `oldValue` respectively to better reflect their function. Just like Combo's `value`, those will emit either the specified property values or full data items depending on whether `valueKey` is set or not. Automatic migrations are available and will be applied on `ng update`.
- `IComboSelectionChangingEventArgs` exposes two new properties `newSelection` and `oldSelection` in place of the old ones that are no longer affected by `valueKey` and consistently emit items from Combo's `data`.

Note: In remote data scenarios with `valueKey` set, selected items that are not currently part of the loaded data chunk will be emitted a partial item data object with the `valueKey` property.
- **Breaking Change** - `IComboSelectionChangingEventArgs` properties `added` and `removed` now always contain data items, regardless of `valueKey` being set. This aligns them with the updated `newSelection` and `oldSelection` properties, including the same limitation for remote data as described above.
- `IgxSimpleCombo`
- **Breaking Change** - `ISimpleComboSelectionChangingEventArgs` properties `newSelection` and `oldSelection` have been renamed to `newValue` and `oldValue` respectively to better reflect their function. Just like Combo's `value`, those will emit either the specified property value or full data item depending on whether `valueKey` is set or not. Automatic migrations are available and will be applied on `ng update`.
- `ISimpleComboSelectionChangingEventArgs` exposes two new properties `newSelection` and `oldSelection` in place of the old ones that are no longer affected by `valueKey` and consistently emit items from Combo's `data`.

Note: In remote data scenarios with `valueKey` set, selected items that are not currently part of the loaded data chunk will be emitted a partial item data object with the `valueKey` property.
## 16.1.4
### New Features
- `Themes`:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "../../common/schema/members-changes.schema.json",
"changes": [
{
"member": "newSelection",
"replaceWith": "newValue",
"definedIn": [
"IComboSelectionChangingEventArgs",
"ISimpleComboSelectionChangingEventArgs"
]
},
{
"member": "oldSelection",
"replaceWith": "oldValue",
"definedIn": [
"IComboSelectionChangingEventArgs",
"ISimpleComboSelectionChangingEventArgs"
]
}
]
}
60 changes: 60 additions & 0 deletions projects/igniteui-angular/migrations/update-17_0_0/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,66 @@ describe(`Update to ${version}`, () => {
);
});

it('Should properly rename newSelection and oldSelection property to newValue and oldValue in Combo', async () => {
pending('set up tests for migrations through lang service');
appTree.create('/testSrc/appPrefix/component/test.component.ts',
`
import { IgxComboComponent, IComboSelectionChangingEventArgs } from 'igniteui-angular';
export class MyClass {
public handleSelectionChanging(e: IComboSelectionChangingEventArgs) {
const newSelection = e.newSelection;
const oldSelection = e.oldSelection;
}
}
`);

const tree = await schematicRunner.runSchematic(migrationName, {}, appTree);

expect(
tree.readContent('/testSrc/appPrefix/component/test.component.ts')
).toEqual(
`
import { IgxComboComponent, IComboSelectionChangingEventArgs } from 'igniteui-angular';
export class MyClass {
public handleSelectionChanging(e: IComboSelectionChangingEventArgs) {
const newSelection = e.newValue;
const oldSelection = e.oldValue;
}
}
`
);
});

it('Should properly rename newSelection and oldSelection property to newValue and oldValue SimpleCombo', async () => {
pending('set up tests for migrations through lang service');
appTree.create('/testSrc/appPrefix/component/test.component.ts',
`
import { IgxSimpleComboComponent, ISimpleComboSelectionChangingEventArgs } from 'igniteui-angular';
export class MyClass {
public handleSelectionChanging(e: ISimpleComboSelectionChangingEventArgs) {
const newSelection = e.newSelection;
const oldSelection = e.oldSelection;
}
}
`);

const tree = await schematicRunner.runSchematic(migrationName, {}, appTree);

expect(
tree.readContent('/testSrc/appPrefix/component/test.component.ts')
).toEqual(
`
import { IgxComboComponent, IComboSelectionChangingEventArgs } from 'igniteui-angular';
export class MyClass {
public handleSelectionChanging(e: IComboSelectionChangingEventArgs) {
const newSelection = e.newValue;
const oldSelection = e.oldValue;
}
}
`
);
});

for (const igPackage of ['igniteui-angular', '@infragistics/igniteui-angular']) {
it('should move animation imports from igniteui-angular to igniteui-angular/animations', async () => {
appTree.create(`/testSrc/appPrefix/component/test.component.ts`,
Expand Down
12 changes: 7 additions & 5 deletions projects/igniteui-angular/src/lib/combo/combo.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1295,11 +1295,13 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
return keys;
}

// map keys vs. filter data to retain the order of the selected items
return keys.map(key => isNaNvalue(key)
? this.data.find(entry => isNaNvalue(entry[this.valueKey]))
: this.data.find(entry => entry[this.valueKey] === key))
.filter(e => e !== undefined);
return keys.map(key => {
const item = isNaNvalue(key)
? this.data.find(entry => isNaNvalue(entry[this.valueKey]))
: this.data.find(entry => entry[this.valueKey] === key);

return item !== undefined ? item : { [this.valueKey]: key };
damyanpetev marked this conversation as resolved.
Show resolved Hide resolved
});
}

protected checkMatch(): void {
Expand Down
Loading
Loading