How can I add autocomplete input field to Confluence macro?


We maintain a self-made Confluence plugin which no longer works as expected after upgrading Confluence from version 6.13.4 to 7.4.5. The plugin fetches a long list of items from an external source and let’s the user pick an item via an autocompleted input field. I’ve tracked down the problem to a very minimal example of what essentially happens in our code. An input field is added to the DOM and a list of values for autocompletion is added to it:

$("#macro-insert-container .macro-input-fields").append("<input id='test-input' type='text'/>") 
    source: [ "Choice1", "Choice2" ]

This autocomplete() no longer works as before, the input field no longer shows any dropdown menu and no signs of autocompletion. All I find is a new ol element that got created:

<input id="test-input" type="text">
<ol class="autocompleter" style="position: absolute; width: 175px; margin: -1px 0px 0px; display: none;"></ol>

Interestingly enough, this introduces a new effect that I don’t understand. When typing some characters into the input field, a GET request gets issued to this URL (resulting in error 404):

Any ideas what’s going on here and why our autocompletion stopped working?
What is the recommended way of implementing an autocompleted input field?


Hi @dokaspar,
As far as I understand you want set autocompleted field that gets data from external source in macro browser window. As a solution I propose you use Select2 for autocompleted field. See If you need full example how to implement it, please let me know.