Problem/Motivation
Currently, the autocomplete derived form Drupal's misc/autocomplete.js is such that when the user hits the enter key, the search is immediately submitted. This causes issues with certain kinds of CJK key entry, which requires the compilation of radicals / syllables into character sets and require enter as a confirmation. This causes the form to be immediately submitted with a potentially undesired query.
Proposed resolution
Modify the javascript behavior to recognize when the field contains the set of characters that indicate a CJK style input, use appropriate key detect to account for the enter-term completion and ajax autocomplete.
Comments
Comment #1
angrytoast commentedPatch attached:
Comment #2
iamEAP commentedThanks, @angrytoast! Testing indicates the patch is functional. A number of code style issues, though. Should be a quick cleanup.
For reference, Drupal JavaScript coding standards.
Adds whitespace.
More whitespace; though not in the official standards, it might be good to keep consistent code style on variable declarations. Perhaps a new "var" per line?
More whitespace; also comments should start with a capital letter and end with a period.
Code style issue: remove all spaces from within control structures.
Whitespace within control structures again. Also there should be a space between the control structure and the boolean phrase. e.g. if (...) as opposed to if(...)
Also, "else" phrases should be on a new line, below the closing brace of the "if"
Adds whitespace.
Another instance of whitespace within control structures.
Another instance of the "else" starting on the same line as the closing "if" brace.
Comment #3
angrytoast commentedUpdated with coding style fixes:
Comment #4
iamEAP commentedAh, patch doesn't apply. You'll need to make the patch from the project root / repo, as opposed to your Drupal root. Otherwise, looks good.
See git instructions and/or Creating Drupal patches with git.
Comment #5
angrytoast commentedRegenerated patch with drupal git repo structure:
Comment #6
iamEAP commentedCommitted fbe1431
Thanks for your contribution!