DEV Community

Leo
Leo

Posted on Originally published at news.html.to

Safari Technology Preview 257 puts the native multi-select in a dropdown

Somewhere in your codebase there is probably a tag picker. It is a div that opens a panel of checkboxes, with a row of removable chips on top and a few hundred lines of script holding it together. Someone wrote it because the native <select multiple> takes up too much room and can't be styled. Keyboard users and screen-reader users get to find out how well that script handles arrow keys, selection state and announcements, and in my experience it usually handles them badly.

Safari Technology Preview 257 is one more step toward never writing that widget again. The build came out on November 18 for macOS Golden Gate and macOS Tahoe and covers WebKit changes 324654@main through 326096@main. Two lines in its Forms section are about the multi-select.

The two new features

The first is plain HTML with nothing to opt into. WebKit added support for rendering <select multiple size="1"> as a dropdown box on macOS. Leave size off and a multi-select shows up as the familiar scrolling list box, eating vertical space. Ask for one visible row on macOS and this build now gives you a collapsed control that opens when activated.

The second is a preview, and it is off by default. WebKit added preview support for the enhanced <select> element with the multiple attribute and list box rendering. The same change clones every selected option into selectedcontent elements, so a multi-select can show all of its current choices in the closed control, not just one.

That second line matters more than it looks. The usual excuse for a scripted multi-select is the closed state: designers want the chosen values visible as a summary, and the native control couldn't do it. If selectedcontent can hold every selected option, that excuse gets a lot weaker.

Trying the native version first

You can test the first feature today with markup you may already have:

<label for="toppings">Toppings</label>
<select id="toppings" name="toppings" multiple size="1">
  <option>Basil</option>
  <option>Olives</option>
  <option>Mushrooms</option>
</select>
Enter fullscreen mode Exit fullscreen mode

Keep the <label>. A collapsed control still needs an accessible name. Keep real text in every <option> too, because the option text is what assistive tech has to work with when the list is closed. The enhanced version is off by default, so you have to turn it on yourself. The release notes don't name the setting, so I won't guess at it.

Fixes that touch form state and focus

The Forms section also lists repairs to controls you ship today:

  • A <select> whose form state was restored no longer keeps showing the previously selected option. A visible value that disagrees with the submitted value misleads everyone, and someone who can't easily re-check the control may never notice.
  • <selectedcontent> elements of a <select> now all update when one of them is moved.
  • Listbox <select> elements now baseline-align like vertical-align: text-bottom, which WebKit says is consistent with other browsers.
  • Clicking an <input type="file"> is now accepted with transient user activation, the same way showPicker() is. Per the notes, this fixes file pickers that failed to open on some sites.
  • A scrollable <textarea> no longer jumps on the first edit below the visible area.

Outside Forms, three fixes are relevant to accessibility. SVG <a>, <g> and nested <svg> elements now render outline, including the default :focus ring. Before this, keyboard users focusing a link inside an inline SVG chart or map in this engine could get no visible indicator at all. Text set with text-combine-upright now returns the combined text, instead of U+FFFC, to innerText, copy, and accessibility. And element.focus() now dispatches focus as well as focusin while the page isn't focused.

What the notes don't tell you

The release notes make no claim about how VoiceOver or any other assistive tech announces the dropdown multi-select, or the enhanced one. Don't assume it works well because it's native. Test it. Open it with the keyboard, select several options, close it, and listen to what the closed state says. Then check the submitted values.

Where support stands

Both features are listed for Safari Technology Preview 257 only, and the dropdown rendering is specific to macOS. The enhanced multi-select is a preview behind a setting that is off by default. The notes say nothing about other engines or a stable Safari release, so treat this as something to test now and not yet something to ship.

My verdict

This is the right direction. Making the native control fit the design is better than shipping another fragile copy. Before your next forms PR:

  • Try <select multiple size="1"> in Technology Preview before you reach for a scripted picker.
  • Give every multi-select a <label>, and give every <option> real text.
  • Test the closed state with a screen reader, not just the open list.
  • If you put links inside inline SVG, check that their focus ring shows up in this build.

Top comments (0)