Skip to content

Commit

Permalink
fix(module: search-bar) fix IME input (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
to0simple committed Nov 18, 2020
1 parent 9089a24 commit c184b27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/search-bar/search-bar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<i class="{{ prefixCls }}-synthetic-ph-icon"></i>
<span
class="{{ prefixCls }}-synthetic-ph-placeholder"
[ngStyle]="{ visibility: placeholder && !value ? 'visible' : 'hidden' }"
[ngStyle]="{ visibility: placeholder && !isComposing && !value ? 'visible' : 'hidden' }"
>
{{ placeholder }}
</span>
Expand All @@ -28,6 +28,8 @@
(blur)="onSearchbarBlur()"
(focus)="onSearchbarFocus()"
(ngModelChange)="onSearchbarChange($event)"
(compositionstart)="onSetCompositionState(true)"
(compositionend)="onSetCompositionState(false)"
/>
<a [ngClass]="clearCls" style="box-sizing: content-box;transition: 0s" (click)="onSearchbarClear()"></a>
</div>
Expand Down
5 changes: 5 additions & 0 deletions components/search-bar/search-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class SearchBarComponent implements OnInit, AfterViewInit, AfterViewCheck
cancelCls: object = {
[`${this.prefixCls}-cancel`]: true
};
isComposing = false;

private _defaultValue: string = '';
private _value: string = '';
Expand Down Expand Up @@ -250,6 +251,10 @@ export class SearchBarComponent implements OnInit, AfterViewInit, AfterViewCheck
this.onSearchbarFocus();
}

onSetCompositionState(isComposing: boolean) {
this.isComposing = isComposing;
}

writeValue(value: any): void {
this._value = value || '';
this.inputElementRef.nativeElement.value = this._value;
Expand Down

0 comments on commit c184b27

Please sign in to comment.