Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

multiple

Lets a select, an email input or a file input hold more than one value. Covers select size, the email list format and how each control submits its values.

Overview

multiple is a boolean attribute that lets a control accept more than one value. It means something different on each element: a listbox where several options can be selected, an email field that takes a comma-separated list, or a file picker that returns several files.

Applies to: <select>, and <input> of type email and file.

Values

Boolean: present allows several values; multiple="false" still does. Remove the attribute for a single value.

ElementWith multipleSubmitted asRead in script
<select>A listbox; any number of options selectedOne name=value pair per selected optionselect.selectedOptions, formData.getAll(name)
type="email"A comma-separated list, each address validatedOne pair; the addresses joined by commas with no spacesinput.value.split(',')
type="file"The picker allows several filesOne pair per fileinput.files, formData.getAll(name)

size on <select>

size sets how many rows a select shows. A select renders as a listbox when it has multiple or a size above 1; otherwise it is a dropdown. The default display size is 4 with multiple and 1 without.

Examples

Email list

The browser trims whitespace around each address, so [email protected], [email protected] becomes [email protected],[email protected]. Each address must be valid (and must match pattern, if set) or the field is typeMismatch.

"Pick between N and M": checkboxes, not a listbox

A multi-select listbox needs modifier keys to add a second option, and one plain click clears the rest. For a handful of options, checkboxes are clearer, and a data-validate form can count them.

Reading values

In Vanilla Breeze

  • Select styling. The dropdown chevron and the customizable-select enhancement (appearance: base-select) apply only to single-row selects: no multiple, and size absent, 0 or 1 (src/native-elements/input/styles.css, src/native-elements/input/select.css). A multiple or size greater than 1 select keeps the native listbox, so its options stay scrollable.
  • data-upload turns a file input into a drop zone with a file list. Dropped files go through the same rules as the picker: without multiple only the first is kept (and the user is told), and files that don't match accept are named and left out (src/utils/upload-init.js). A new pick or drop replaces the selection; files are not accumulated.
  • Checkbox groups. fieldset[data-min-checked] / [data-max-checked] in a data-validate form, data-select-all for a master checkbox, and data-toggle-tags for tag-style choices.
  • Components. <combo-box> has a multiple mode that shows selected items as tags, for long or searchable lists.

Accessibility

  • A <select multiple> is a listbox. Mouse users add options with Ctrl or Cmd + click and ranges with Shift + click; keyboard users extend with Shift + arrow keys, and adding a single non-adjacent option by keyboard differs by platform. Many users know none of this, so explain it in a hint, or use checkboxes.
  • For an email list, say how to separate addresses in visible hint text; the format is not obvious.
  • data-upload adds a named list of the files and announces rejected files in a status line.

Browser support

multiple works everywhere. Safari on iOS ignores size and shows a select as a picker; Chrome for Android honours size from version 142.

Gotchas

  • formData.get() returns only the first value. Use getAll() for multiple selects and files.
  • required on <select multiple> means at least one option. There is no native "at least two".
  • Opening the file picker again replaces the earlier selection rather than adding to it.
  • multiple on other input types does nothing.

Related

Which to choose

  • Checkboxes (+ data-min-checked) — up to about ten options, all visible.
  • <select multiple> — a long list in a small space, for users who know the modifier keys (admin tools).
  • <combo-box> — a long or searchable list where selected items show as tags.
  • type="email" multiple — a handful of addresses typed by hand.
↑