heikkilevanto / beertracker

Simple script to track the beers I drink
GNU General Public License v2.0
2 stars 1 forks source link

Browser suggestions for input fields #357

Closed heikkilevanto closed 3 weeks ago

heikkilevanto commented 3 months ago

There is a way to pass a list of values to an input field, which makes the browser offer them as autocompletes. Make such lists for all fields, depending on the current record type, so switching to wine will prefill wine names and makers.

Also, pass some of the most recent entries to the JS. When entering a name, check if we know it, and in that case, prefill style, maker, alc, etc. (See also #59 for the leading-space trick not to overwrite human-entered values)

heikkilevanto commented 3 months ago

See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#list and https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist

heikkilevanto commented 1 month ago

Got hard-coded wine subtypes to work, at least on my desktop machine. Not so much luck on my phone. (Firefox on both)

Did experiment with autocomplete='beertracker subtype' which again works on my desktop. On t he desktop shows two lists of autocompletes, a generic one, and one for this field. Seems to do nothing on my phone.

Will need to collect various lists when parsing records, and make suitable lists of them. Something like beer names should depend on the brewery, so needs to be updated at runtime, in the browser.

Actually, for some fields a regular select type would be better. At least for wine subtypes and others that can be hardcoded to a well defined set.

heikkilevanto commented 3 weeks ago

Ah, I must be doing something right, as the suggestions work in Chrome on my phone.

Indeed, there is a suggestion to add this to Android Firefox: https://connect.mozilla.org/t5/ideas/firefox-mobile-amp-datalist

Looks like that is all I can do for now. Unless I want to implement a big javascript cludge that starts as a fixed list, but allows free text entry as well. Don't think I will get to it.

Closing this now. If Mozilla ever gets the datalists to work, the wine styles should magically start to work. Reopen then, and implement the same for many other fields. No point doing it before then.

heikkilevanto commented 3 weeks ago

See also a workaround in https://stackoverflow.com/questions/18082612/html5-datalist-tag-is-not-working-in-android#18082844