3 ms·
Please don't go adding this to your production websites. It's incredibly buggy when using any kind of non-standard input. A few examples: * IME input is broken
by underwater 13y ago
Please don't go adding this to your production websites. It's incredibly buggy when using any kind of non-standard input. A few examples:
* IME input is broken. If I type "s" and "a" with my keyboard set to Katakana I should see "サ" and not "sア".
* Adding accented characters on OS X (hold down a vowel key) doesn't do what I'd expect. Pressing "e" and selecting a variant inserts the first suggestion giving me "êven".
* Entering text at the beginning of input is not possible. Trying to do so constantly moves the cursor to the end.
* Spellcheck underlines disappear. Browsers won't recheck the entire input after each keystroke, just the last few words. They also stop underlining when you change the input value. This means that any incorrectly spelled words lose their highlight if not near the cursor.
* There seems to be no consideration for how this will work for users who rely on a screen reader.
Few of these browser and OS features expose APIs to JavaScript. You have to build your application around their behavior from the ground up. The approach used by this script of mutating the value and modifying selection is completely broken.
- underwater 13y agoThis effect is better achieved by using two nodes. At Facebook we have the main input positioned over a node that shows the same content with the suffix appended. This is the same technique we use to show highlighted names in the comment field.