Merge pull request #5667 from kidonng/patch-1

luci-app-opkg: listen to filter `input` event
This commit is contained in:
Jo-Philipp Wich 2022-02-24 09:04:43 +01:00 committed by GitHub
commit 843d5bdecb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -994,13 +994,13 @@ function updateLists(data)
}); });
} }
var keyTimeout = null; var inputTimeout = null;
function handleKeyUp(ev) { function handleInput(ev) {
if (keyTimeout !== null) if (inputTimeout !== null)
window.clearTimeout(keyTimeout); window.clearTimeout(inputTimeout);
keyTimeout = window.setTimeout(function() { inputTimeout = window.setTimeout(function() {
display(ev.target.value); display(ev.target.value);
}, 250); }, 250);
} }
@ -1027,7 +1027,7 @@ return view.extend({
E('div', {}, [ E('div', {}, [
E('label', {}, _('Filter') + ':'), E('label', {}, _('Filter') + ':'),
E('span', { 'class': 'control-group' }, [ E('span', { 'class': 'control-group' }, [
E('input', { 'type': 'text', 'name': 'filter', 'placeholder': _('Type to filter…'), 'value': query, 'keyup': handleKeyUp }), E('input', { 'type': 'text', 'name': 'filter', 'placeholder': _('Type to filter…'), 'value': query, 'input': handleInput }),
E('button', { 'class': 'btn cbi-button', 'click': handleReset }, [ _('Clear') ]) E('button', { 'class': 'btn cbi-button', 'click': handleReset }, [ _('Clear') ])
]) ])
]), ]),