Fix glitchy UI dropdown select for max downloads and expiration
This commit is contained in:
parent
bcfb9c5d09
commit
46381fd516
|
@ -1,32 +1,28 @@
|
|||
const html = require('choo/html');
|
||||
|
||||
module.exports = function(selected, options, translate, changed, htmlId) {
|
||||
let x = selected;
|
||||
function choose(event) {
|
||||
if (event.target.value != selected) {
|
||||
console.log('Selected new value from dropdown', htmlId, ':', selected, '->', event.target.value)
|
||||
changed(event.target.value);
|
||||
}
|
||||
}
|
||||
|
||||
return html`
|
||||
<select
|
||||
id="${htmlId}"
|
||||
class="appearance-none cursor-pointer border rounded bg-grey-10 hover:border-blue-50 focus:border-blue-50 pl-1 pr-8 py-1 my-1 h-8 dark:bg-grey-80"
|
||||
data-selected="${selected}"
|
||||
onchange="${choose}"
|
||||
>
|
||||
${options.map(
|
||||
i =>
|
||||
value =>
|
||||
html`
|
||||
<option value="${i}" ${i === selected ? 'selected' : ''}
|
||||
>${translate(i)}</option
|
||||
>
|
||||
<option value="${value}" ${value == selected ? 'selected' : ''}>
|
||||
${translate(value)}
|
||||
</option>
|
||||
`
|
||||
)}
|
||||
</select>
|
||||
`;
|
||||
|
||||
function choose(event) {
|
||||
const target = event.target;
|
||||
const value = +target.value;
|
||||
|
||||
if (x !== value) {
|
||||
x = value;
|
||||
changed(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue