Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion core/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class Input implements ComponentInterface {
private inputId = `ion-input-${inputIds++}`;
private didBlurAfterEdit = false;
private inheritedAttributes: { [k: string]: any } = {};
private isComposing = false;

/**
* This is required for a WebKit bug which requires us to
Expand Down Expand Up @@ -231,7 +232,7 @@ export class Input implements ComponentInterface {
*/
@Watch('value')
protected valueChanged() {
if (this.nativeInput) {
if (this.nativeInput && !this.isComposing) {
/**
* Assigning the native input's value on attribute
* value change, allows `ionInput` implementations
Expand Down Expand Up @@ -260,12 +261,27 @@ export class Input implements ComponentInterface {
}
}

componentDidLoad() {
const nativeInput = this.nativeInput;
if (nativeInput) {
// TODO: FW-729 Update to JSX bindings when Stencil resolves bug with:
// https://github.com/ionic-team/stencil/issues/3235
nativeInput.addEventListener('compositionstart', this.onCompositionStart);
nativeInput.addEventListener('compositionend', this.onCompositionEnd);
}
}

disconnectedCallback() {
if (Build.isBrowser) {
document.dispatchEvent(new CustomEvent('ionInputDidUnload', {
detail: this.el
}));
}
const nativeInput = this.nativeInput;
if (nativeInput) {
nativeInput.removeEventListener('compositionstart', this.onCompositionStart);
nativeInput.removeEventListener('compositionEnd', this.onCompositionEnd);
}
}

/**
Expand Down Expand Up @@ -364,6 +380,14 @@ export class Input implements ComponentInterface {
}
}

private onCompositionStart = () => {
this.isComposing = true;
}

private onCompositionEnd = () => {
this.isComposing = false;
}

private clearTextOnEnter = (ev: KeyboardEvent) => {
if (ev.key === 'Enter') { this.clearTextInput(ev); }
}
Expand Down