Skip to content

Commit 9aaf8ba

Browse files
authored
fix(simple-combo): handle paste event - 17.0.x (#13789)
1 parent 9548494 commit 9aaf8ba

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
@@ -1490,6 +1490,33 @@ describe('IgxSimpleCombo', () => {
14901490
fixture.detectChanges();
14911491
expect(combo.displayValue).toEqual('Ohio ');
14921492
}));
1493+
1494+
it('should properly filter dropdown when pasting from clipboard in input', () => {
1495+
spyOn(combo, 'handleInputChange').and.callThrough();
1496+
combo.open();
1497+
input.triggerEventHandler('focus', {});
1498+
fixture.detectChanges();
1499+
1500+
const target = {
1501+
value: combo.data[1].field
1502+
}
1503+
combo.comboInput.value = target.value
1504+
const pasteData = new DataTransfer();
1505+
const pasteEvent = new ClipboardEvent('paste', { clipboardData: pasteData });
1506+
Object.defineProperty(pasteEvent, 'target', {
1507+
writable: false,
1508+
value: target
1509+
})
1510+
input.triggerEventHandler('paste', pasteEvent);
1511+
fixture.detectChanges();
1512+
1513+
expect(combo.handleInputChange).toHaveBeenCalledTimes(1);
1514+
expect(combo.handleInputChange).toHaveBeenCalledWith(jasmine.objectContaining({
1515+
target: jasmine.objectContaining({ value: target.value })
1516+
}));
1517+
expect(combo.filteredData.length).toBeLessThan(combo.data.length)
1518+
expect(combo.filteredData[0].field).toBe(target.value)
1519+
});
14931520
});
14941521

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

0 commit comments

Comments
 (0)