JSFiddle - React, Tailwind, and code Playground

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/vader/jquery-ui.css">
<div>Double click the "th" below to enter edit mode. Press down arrow to open the autocomplete menu. Pressing escape returns to read mode.  Pressing enter commits the change.</div>
<div><span id="read" style="border:1px #000 solid;">th</span><input id="edit" type="text" value="th" style="display:none;"/>

JavaScript

function enterEditMode() {
    $("#read").hide();
    $("#edit").show().focus();
}

function exitEditMode() {
    $("#read").show();
    $("#edit").hide();
}

function commitChanges() {
    $("#read").text($("#edit").val());
    exitEditMode();
}

$(function() {
    $("#read").dblclick(enterEditMode);
    $("#edit").keydown(function(event) {
        if (event.keyCode === 27) exitEditMode();
        else if (event.keyCode === 13) commitChanges();
    }).autocomplete({
        source: ["this", "that", "the other"]
    });
});