From 413628a0466e95f79a38af2a520d99938087cb83 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Sat, 15 Jan 2022 16:37:49 -0800 Subject: [PATCH] Apply normalization on CandidateBox selection --- src/lib/components/Keyboard.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/components/Keyboard.ts b/src/lib/components/Keyboard.ts index 82a70f69..49bebdba 100644 --- a/src/lib/components/Keyboard.ts +++ b/src/lib/components/Keyboard.ts @@ -365,6 +365,10 @@ class SimpleKeyboard { candidateValue, targetElement, onSelect: (selectedCandidate: string, e: MouseEvent) => { + /** + * Making sure that our suggestions are not composed characters + */ + const normalizedCandidate = selectedCandidate.normalize("NFD"); const currentInput = this.getInput(this.options.inputName, true); const initialCaretPosition = this.getCaretPositionEnd() || 0; const inputSubstr = @@ -372,7 +376,10 @@ class SimpleKeyboard { currentInput; const regexp = new RegExp(`${candidateKey}$`, "gi"); - const newInputSubstr = inputSubstr.replace(regexp, selectedCandidate); + const newInputSubstr = inputSubstr.replace( + regexp, + normalizedCandidate + ); const newInput = currentInput.replace(inputSubstr, newInputSubstr); const caretPositionDiff = newInputSubstr.length - inputSubstr.length;