Skip to content

Commit

Permalink
Fix typeahead bugs on modal
Browse files Browse the repository at this point in the history
  • Loading branch information
marcodpt committed Oct 15, 2024
1 parent de23e44 commit 68eecb4
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/ctrl/inputs/typeahead/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ export default ({
(options.length == 1 && options[0].value == value),
oninput: () => {
list.classList.remove('d-none')
search(field.value)
var old = field.value
setTimeout(() => {
if (old == field.value) {
search(field.value)
}
}, 500)
},
onfocus: () => open(),
onmousedown: () => list.classList.contains('d-none') ? open() : close(),
Expand All @@ -130,6 +135,7 @@ export default ({
select()
} else if (key(['Escape'])) {
close()
ev.stopPropagation()
}
}
}
Expand All @@ -154,7 +160,10 @@ export default ({
'list-group-item-action',
i == active ? 'active' : ''
],
onclick: () => select(i)
onclick: ev => {
ev.preventDefault()
select(i)
}
}, [
text(o.label)
])
Expand Down
2 changes: 0 additions & 2 deletions src/modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,4 @@ export default ({
document.body.appendChild(modal)
M = new bootstrap.Modal(modal)
M.show()

return modal
})
261 changes: 261 additions & 0 deletions src/modal/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,267 @@ export default ({
data: [
{}
]
}, {
title: 'Countries',
data: [
{
title: 'Coutries',
properties: {
name: {
title: 'Name',
type: 'string'
},
country: {
title: 'Country',
type: 'string',
enum: [
"Afghanistan",
"Albania",
"Algeria",
"Andorra",
"Angola",
"Anguilla",
"Antigua & Barbuda",
"Argentina",
"Armenia",
"Aruba",
"Australia",
"Austria",
"Azerbaijan",
"Bahamas",
"Bahrain",
"Bangladesh",
"Barbados",
"Belarus",
"Belgium",
"Belize",
"Benin",
"Bermuda",
"Bhutan",
"Bolivia",
"Bosnia & Herzegovina",
"Botswana",
"Brazil",
"British Virgin Islands",
"Brunei",
"Bulgaria",
"Burkina Faso",
"Burundi",
"Cambodia",
"Cameroon",
"Canada",
"Cape Verde",
"Cayman Islands",
"Central Arfrican Republic",
"Chad",
"Chile",
"China",
"Colombia",
"Congo",
"Cook Islands",
"Costa Rica",
"Cote D Ivoire",
"Croatia",
"Cuba",
"Curacao",
"Cyprus",
"Czech Republic",
"Denmark",
"Djibouti",
"Dominica",
"Dominican Republic",
"Ecuador",
"Egypt",
"El Salvador",
"Equatorial Guinea",
"Eritrea",
"Estonia",
"Ethiopia",
"Falkland Islands",
"Faroe Islands",
"Fiji",
"Finland",
"France",
"French Polynesia",
"French West Indies",
"Gabon",
"Gambia",
"Georgia",
"Germany",
"Ghana",
"Gibraltar",
"Greece",
"Greenland",
"Grenada",
"Guam",
"Guatemala",
"Guernsey",
"Guinea",
"Guinea Bissau",
"Guyana",
"Haiti",
"Honduras",
"Hong Kong",
"Hungary",
"Iceland",
"India",
"Indonesia",
"Iran",
"Iraq",
"Ireland",
"Isle of Man",
"Israel",
"Italy",
"Jamaica",
"Japan",
"Jersey",
"Jordan",
"Kazakhstan",
"Kenya",
"Kiribati",
"Kosovo",
"Kuwait",
"Kyrgyzstan",
"Laos",
"Latvia",
"Lebanon",
"Lesotho",
"Liberia",
"Libya",
"Liechtenstein",
"Lithuania",
"Luxembourg",
"Macau",
"Macedonia",
"Madagascar",
"Malawi",
"Malaysia",
"Maldives",
"Mali",
"Malta",
"Marshall Islands",
"Mauritania",
"Mauritius",
"Mexico",
"Micronesia",
"Moldova",
"Monaco",
"Mongolia",
"Montenegro",
"Montserrat",
"Morocco",
"Mozambique",
"Myanmar",
"Namibia",
"Nauro",
"Nepal",
"Netherlands",
"Netherlands Antilles",
"New Caledonia",
"New Zealand",
"Nicaragua",
"Niger",
"Nigeria",
"North Korea",
"Norway",
"Oman",
"Pakistan",
"Palau",
"Palestine",
"Panama",
"Papua New Guinea",
"Paraguay",
"Peru",
"Philippines",
"Poland",
"Portugal",
"Puerto Rico",
"Qatar",
"Reunion",
"Romania",
"Russia",
"Rwanda",
"Saint Pierre & Miquelon",
"Samoa",
"San Marino",
"Sao Tome and Principe",
"Saudi Arabia",
"Senegal",
"Serbia",
"Seychelles",
"Sierra Leone",
"Singapore",
"Slovakia",
"Slovenia",
"Solomon Islands",
"Somalia",
"South Africa",
"South Korea",
"South Sudan",
"Spain",
"Sri Lanka",
"St Kitts & Nevis",
"St Lucia",
"St Vincent",
"Sudan",
"Suriname",
"Swaziland",
"Sweden",
"Switzerland",
"Syria",
"Taiwan",
"Tajikistan",
"Tanzania",
"Thailand",
"Timor L'Este",
"Togo",
"Tonga",
"Trinidad & Tobago",
"Tunisia",
"Turkey",
"Turkmenistan",
"Turks & Caicos",
"Tuvalu",
"Uganda",
"Ukraine",
"United Arab Emirates",
"United Kingdom",
"United States of America",
"Uruguay",
"Uzbekistan",
"Vanuatu",
"Vatican City",
"Venezuela",
"Vietnam",
"Virgin Islands (US)",
"Yemen",
"Zambia",
"Zimbabwe"
]
},
age: {
title: 'Age',
type: 'number'
}
},
submit: data => {
console.log(data)
},
links: [
{
context: 'secondary',
icon: 'times',
title: 'Close',
bs: {
dismiss: 'modal'
}
}, {
title: 'Submit',
href: 'submit'
}
]
}
]
}
]
})
3 changes: 2 additions & 1 deletion views/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default X => {
const {title, description, data, html} = mod.default.examples[Params.index]
const desc = normalizeDesc(description)
highlight()
const component = (mod.default.component || X[P[0]])(data[0])
return node(({div, h5, p, hr, text, pre, code}) => div({
class: 'container my-5 mx-auto'
}, [
Expand All @@ -34,7 +35,7 @@ export default X => {
]),
hr(),
div({}, [
(mod.default.component || X[P[0]])(data[0])
component
]),
hr(),
p({
Expand Down

0 comments on commit 68eecb4

Please sign in to comment.