Skip to content

Commit ce20956

Browse files
authored
fix(autocomplete): japanese input support for Chrome on Mac #11988 (#12328)
1 parent a60086f commit ce20956

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

projects/igniteui-angular/src/lib/directives/autocomplete/autocomplete.directive.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,14 @@ describe('IgxAutocomplete', () => {
781781
fixture.detectChanges();
782782
expect(input.nativeElement.attributes['aria-expanded'].value).toEqual('false');
783783
}));
784+
it('Should accept Japanese input', fakeAsync(() => {
785+
UIInteractions.setInputElementValue(input, '東京', fixture);
786+
fixture.detectChanges();
787+
tick();
788+
UIInteractions.triggerKeyDownEvtUponElem('enter', input.nativeElement, true);
789+
fixture.detectChanges();
790+
expect(input.value).toBe('東京');
791+
}));
784792
});
785793
describe('Positioning settings tests', () => {
786794
it('Panel settings - direction and startPoint: top', fakeAsync(() => {

projects/igniteui-angular/src/lib/directives/autocomplete/autocomplete.directive.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export class IgxAutocompleteDirective extends IgxDropDownItemNavigationDirective
211211
return 'list';
212212
}
213213

214+
protected _composing: boolean;
214215
protected id: string;
215216
protected get model() {
216217
return this.ngModel || this.formControl;
@@ -234,6 +235,20 @@ export class IgxAutocompleteDirective extends IgxDropDownItemNavigationDirective
234235
this.open();
235236
}
236237

238+
/** @hidden @internal */
239+
@HostListener('compositionstart')
240+
public onCompositionStart(): void {
241+
if (!this._composing) {
242+
this._composing = true;
243+
}
244+
}
245+
246+
/** @hidden @internal */
247+
@HostListener('compositionend')
248+
public onCompositionEnd(): void {
249+
this._composing = false;
250+
}
251+
237252
/** @hidden @internal */
238253
@HostListener('keydown.ArrowDown', ['$event'])
239254
@HostListener('keydown.Alt.ArrowDown', ['$event'])
@@ -253,7 +268,7 @@ export class IgxAutocompleteDirective extends IgxDropDownItemNavigationDirective
253268

254269
/** @hidden @internal */
255270
public handleKeyDown(event) {
256-
if (!this.collapsed) {
271+
if (!this.collapsed && !this._composing) {
257272
switch (event.key.toLowerCase()) {
258273
case 'space':
259274
case 'spacebar':

0 commit comments

Comments
 (0)