JSFiddle - React, Tailwind, and code Playground

HTML

<input id="search" type="input" />

JavaScript

$(function() {
    
    var availableTags = [
            "item1","item2","item3"
        ];
    
    shouldComplete = true;
   
    $("#search").autocomplete({
        source:function (request, response) {            
            setTimeout(
                function() {
                    response(shouldComplete ? availableTags : null);
                },
                2000);
        }        
        ,
        minLength: 0
        });

    $("#search").keypress(function(e){
    if (!e) e = window.event;   
    if (e.keyCode == '13'){
      $('#search').autocomplete('close');
        shouldComplete = false;
      return false;
    }
        else
        {
            shouldComplete = true;
        }
  });
    
    

});