Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Spell checker #19

Open
wants to merge 7 commits into
base: ccl-v0.26.2
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
label="Spell Checker"
help_text="This is field will autocorrect your spelling"
placeholder="Put something down, for real"
value="I am a good sprller"
value="I am a good sprller, with the additional text that overflows the input field width and should be wrapped and move to the next line"
spellCheckerFunc="spellCheck"
textarea
autogrow
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@greatnonprofits-nfp/temba-components",
"version": "0.26.4",
"version": "0.26.6",
"description": "Web components to support rapidpro and related projects",
"author": "Nyaruka <[email protected]>",
"main": "dist/index.js",
Expand Down
12 changes: 9 additions & 3 deletions src/completion/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const getCompletions = (
const parts = (dotQuery || '').split('.');
let currentProps: CompletionProperty[] = session
? schema.root
: schema.root_no_session;
: schema?.root_no_session;

if (!currentProps) {
return [];
Expand Down Expand Up @@ -279,8 +279,14 @@ export const updateInputElementWithCompletion = (
const caret = leftSide.length + insertText.length;

// set our value and our new caret
ele.value = leftSide + insertText + remaining;
ele.setSelectionRange(caret, caret);
if (ele.tagName === 'DIV' && ele.classList.contains('textinput')) {
ele.innerText = leftSide + insertText + remaining;
ele.value = leftSide + insertText + remaining;
ele.setSelectionRange(caret, caret);
} else {
ele.value = leftSide + insertText + remaining;
ele.setSelectionRange(caret, caret);
}

// now scroll our text box if necessary
const position = getCursorXY(ele, caret);
Expand Down
Loading
Loading