JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="chatMessage"></input>
<ul id="suggestions"></ul>
<button id="change">Change to Spanish</button>

JavaScript

/*!
 * jQuery intlKeyboard Plugin v0.1
 *
 * Copyright 2013 Ashwin Purohit and other contributors
 * Released under the MIT license
 *
 * Date: 24 Aug 2013
 */ (function ($) {
    var ns = function (event) {
        return (event || '') + '.intlKeyboard';
    }

    // Cross-browser set caret position function
    // From http://stackoverflow.com/a/512542/100208
    var setCaretPosition = function (el, caretPos) {
        if (el != null) {
            if (el.createTextRange) {
                var range = el.createTextRange();
                range.move("character", caretPos);
                range.select();
            } else {
                if (el.selectionStart) {
                    el.focus();
                    el.setSelectionRange(caretPos, caretPos);
                } else {
                    el.focus();
                }
            }
        }
    };
    // Cross-browser get caret position function
    // From http://stackoverflow.com/a/4931963/100208
    var getInputSelection = function (el) {
        var start = 0,
            end = 0,
            normalizedValue, range, textInputRange, len, endRange;
        if (typeof el.selectionStart == "number" && typeof el.selectionEnd == "number") {
            start = el.selectionStart;
            end = el.selectionEnd;
        } else {
            range = document.selection.createRange();
            if (range && range.parentElement() == el) {
                len = el.value.length;
                normalizedValue = el.value.replace(/\r\n/g, "\n");
                // Create a working TextRange that lives only in the input
                textInputRange = el.createTextRange();
                textInputRange.moveToBookmark(range.getBookmark());
                // Check if the start and end of the selection are at the very end
                // of the input, since moveStart/moveEnd doesn't return what we want
                // in those cases
                endRange = el.createTextRange();
               ...