Skip to content

Commit b1b4ebb

Browse files
Merge branch '18.0.x' of https://github.com/IgniteUI/igniteui-angular into ganastasov/fix-14200-18.0
2 parents fce9772 + 1b13a6c commit b1b4ebb

File tree

4 files changed

+82
-12
lines changed

4 files changed

+82
-12
lines changed

projects/igniteui-angular/migrations/update-18_0_0/index.spec.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe(`Update to ${version}`, () => {
1919
options: {
2020
styles: [
2121
"/testSrc/styles.scss"
22-
]
22+
] as (string | object)[]
2323
}
2424
}
2525
}
@@ -450,6 +450,36 @@ describe(`Update to ${version}`, () => {
450450
);
451451
});
452452

453+
it('should add default CSS rule to set all components to their previous Large defaults with complex file ref configs', async () => {
454+
const _configJson = JSON.parse(appTree.readContent('/angular.json'));
455+
_configJson.projects.testProj.architect.build.options.styles = [{ input: '/testSrc/styles.scss' }];
456+
appTree.overwrite('/angular.json', JSON.stringify(_configJson));
457+
458+
const tree = await schematicRunner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
459+
expect(tree.readContent('/testSrc/styles.scss')).toEqual(
460+
`
461+
@use "mockStyles.scss";
462+
@forward something;
463+
// Specifies large size for all components to match the previous defaults
464+
// This may not be needed for your project. Please consult https://www.infragistics.com/products/ignite-ui-angular/angular/components/general/update-guide for more details.
465+
:root {
466+
--ig-size: var(--ig-size-large);
467+
}
468+
`
469+
);
470+
});
471+
472+
it('should not throw when applying default CSS rule with complex file ref configs', async () => {
473+
const _configJson = JSON.parse(appTree.readContent('/angular.json'));
474+
_configJson.projects.testProj.architect.build.options.styles = [{ notInput: '/testSrc/styles.scss' }];
475+
appTree.overwrite('/angular.json', JSON.stringify(_configJson));
476+
try {
477+
await schematicRunner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
478+
} catch (e) {
479+
fail(e);
480+
}
481+
});
482+
453483
it('should rename the $active-item-color property to the $icon-selected-color', async () => {
454484
appTree.create(
455485
`/testSrc/appPrefix/component/test.component.scss`,

projects/igniteui-angular/migrations/update-18_0_0/index.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Rule, SchematicContext, SchematicsException, Tree } from "@angular-devkit/schematics";
2-
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';
2+
import { FileChange, findElementNodes, getAttribute, getProjects, getSourceOffset, getWorkspace, hasAttribute, parseFile } from '../common/util';
33
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
44
import type { Element } from '@angular/compiler';
55
import { BoundPropertyObject, InputPropertyType, UpdateChanges } from "../common/UpdateChanges";
@@ -78,16 +78,26 @@ export default (): Rule => async (host: Tree, context: SchematicContext) => {
7878
});
7979

8080
const updateMainCSSFile = (host: Tree, context: SchematicContext): Tree => {
81-
const angularConfigBuffer = host.read('angular.json');
82-
if (!angularConfigBuffer) {
81+
const workspace = getWorkspace(host);
82+
if (!workspace) {
8383
throw new SchematicsException('Could not find angular.json');
8484
}
85-
const angularConfig = JSON.parse(angularConfigBuffer.toString('utf-8'));
8685

87-
for (const project of Object.values<any>(angularConfig.projects)) {
86+
const projects = getProjects(workspace);
87+
for (const project of projects) {
8888
const srcRoot = project.sourceRoot || project.root || '';
89-
const stylesPath = (project.architect?.build?.options?.styles?.filter(s => s.startsWith(srcRoot))[0]) as string;
90-
89+
const stylesPath = project.architect?.build?.options?.styles
90+
?.map((s) => {
91+
if (typeof s === 'string') {
92+
return s;
93+
}
94+
// ref - https://angular.dev/reference/configs/workspace-config#styles-and-scripts-configuration
95+
if (s instanceof Object && 'input' in s) {
96+
return s.input as string;
97+
}
98+
})
99+
.filter((s) => s?.startsWith(srcRoot))[0];
100+
91101
if (!stylesPath) {
92102
context.logger.error(`No styles file found in angular.json for project: ${project}`);
93103
}

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,34 @@ describe('IgxSimpleCombo', () => {
15291529
expect(combo.filteredData[0].field).toBe(target.value)
15301530
});
15311531

1532+
it('should prevent Enter key default behavior when filtering data', fakeAsync(() => {
1533+
const keyEvent = new KeyboardEvent('keydown', { key: 'Enter' });
1534+
const spy = spyOn(keyEvent, 'preventDefault');
1535+
1536+
expect(combo.collapsed).toBe(true);
1537+
expect(combo.selection).toBeUndefined();
1538+
1539+
input.triggerEventHandler('focus', {});
1540+
UIInteractions.simulateTyping('c', input);
1541+
fixture.detectChanges();
1542+
1543+
expect(combo.collapsed).toBe(false);
1544+
1545+
combo.handleKeyDown(keyEvent);
1546+
tick();
1547+
fixture.detectChanges();
1548+
1549+
expect(combo.selection).toBeDefined();
1550+
expect(combo.collapsed).toBe(true);
1551+
expect(spy).toHaveBeenCalled();
1552+
1553+
combo.handleKeyDown(keyEvent);
1554+
tick();
1555+
fixture.detectChanges();
1556+
1557+
expect(spy).toHaveBeenCalledTimes(1);
1558+
}));
1559+
15321560
it('should emit selectionChanging event when input value changes and input loses focus', () => {
15331561
spyOn(combo.selectionChanging, 'emit').and.callThrough();
15341562
fixture.detectChanges();

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,12 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
317317
if (filtered === null || filtered === undefined) {
318318
return;
319319
}
320-
this.select(this.dropdown.focusedItem.itemID);
321-
event.preventDefault();
322-
event.stopPropagation();
323-
this.close();
320+
if (!this.dropdown.collapsed) {
321+
this.select(this.dropdown.focusedItem.itemID);
322+
event.preventDefault();
323+
event.stopPropagation();
324+
this.close();
325+
}
324326
// manually trigger text selection as it will not be triggered during editing
325327
this.textSelection.trigger();
326328
return;

0 commit comments

Comments
 (0)