JSFiddle - React, Tailwind, and code Playground
by thepirat000
HTML
<script src="//api-maps.yandex.ru/2.1/?lang=ru_RU&mode=debug"></script>
<input type="text" id="suggest" style="width: 300px"/>
JavaScript
ymaps.load(function () {
var input = document.getElementById('suggest');
var suggestView = new ymaps.SuggestView('suggest', {
offset: [10, 10]
});
suggestView.state.events.add('change', function () {
setTimeout(function(){
var activeIndex = suggestView.state.get('activeIndex');
if (typeof activeIndex == 'number') {
activeItem = suggestView.state.get('items')[activeIndex];
if (activeItem && activeItem.value != input.value) {
input.value = activeItem.value;
}
}
},2000);
});
});