Skip to content

Commit 8443948

Browse files
authored
fix(simple-combo): handle paste event - 16.1.x (#13787)
1 parent 2331a1f commit 8443948

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
[attr.aria-labelledby]="this.ariaLabelledBy || this.label?.id || this.placeholder"
1919
[attr.placeholder]="placeholder" [disabled]="disabled" [igxTextSelection]="!composing"
2020
(input)="handleInputChange($event)" (click)="handleInputClick()"
21-
(keyup)="handleKeyUp($event)" (keydown)="handleKeyDown($event)" (blur)="onBlur()"/>
21+
(keyup)="handleKeyUp($event)" (keydown)="handleKeyDown($event)" (blur)="onBlur()" (paste)="handleInputChange($event)"/>
2222

2323
<ng-container ngProjectAs="igx-suffix">
2424
<ng-content select="igx-suffix"></ng-content>

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,33 @@ describe('IgxSimpleCombo', () => {
14871487
fixture.detectChanges();
14881488
expect(combo.displayValue).toEqual(['Ohio ']);
14891489
}));
1490+
1491+
it('should properly filter dropdown when pasting from clipboard in input', () => {
1492+
spyOn(combo, 'handleInputChange').and.callThrough();
1493+
combo.open();
1494+
input.triggerEventHandler('focus', {});
1495+
fixture.detectChanges();
1496+
1497+
const target = {
1498+
value: combo.data[1].field
1499+
}
1500+
combo.comboInput.value = target.value
1501+
const pasteData = new DataTransfer();
1502+
const pasteEvent = new ClipboardEvent('paste', { clipboardData: pasteData });
1503+
Object.defineProperty(pasteEvent, 'target', {
1504+
writable: false,
1505+
value: target
1506+
})
1507+
input.triggerEventHandler('paste', pasteEvent);
1508+
fixture.detectChanges();
1509+
1510+
expect(combo.handleInputChange).toHaveBeenCalledTimes(1);
1511+
expect(combo.handleInputChange).toHaveBeenCalledWith(jasmine.objectContaining({
1512+
target: jasmine.objectContaining({ value: target.value })
1513+
}));
1514+
expect(combo.filteredData.length).toBeLessThan(combo.data.length)
1515+
expect(combo.filteredData[0].field).toBe(target.value)
1516+
});
14901517
});
14911518

14921519
describe('Display density', () => {

0 commit comments

Comments
 (0)