Readit News logoReadit News
c-smile · 2 years ago
I do not really understand what is the problem with flexible <select> implementation in browser.

In my Sciter[1] the following are supported ( see screenshot [2] ):

    <select type="dropdown"> - select with popup
    <select type="list"> - select list 
    <select type="tree"> - hierarchical select (a.k.a. tree view) 
and all of them may have

    <select multiple> - multi-select, value = array[]
    <select multiple="checkmarks"> - multi-select, value = array[]
select type="tree" may have also

    <select type="tree" treelines> - draw treelines 
<select> and <option>'s may have arbitrary markup inside (<hr>,<img>, whatever), even more any DOM element may have role="option" defined making it a selectable option :

    <li role="option">...</li>
    <option value="Sc"><code>Sc</code>Scandium</option>
And as a bonus, by declaring different flows in CSS in list you may have:

    select { flow:horizontal; } // horizontal select
    select { flow:vertical-wrap; } // multicolumn select

[1] https://sciter.com [2] https://sciter.com/wp-content/uploads/2024/01/select-variant...

cxr · 2 years ago
> I do not really understand what is the problem with flexible <select> implementation in browser.

There isn't a problem. Your flexibility is just in the wrong place—the flexibility is on the side of the user and user agent, e.g. to manifest and interact with a "<select multiple>" input method however best for the device that the user is looking at the form with. The fact that it's not actually codified anywhere exactly how "<select multiple>" should work is a good thing. Your approach does away with that.

zerocrates · 2 years ago
At least some of this is hopefully on the horizon with the stylable select initiative (this was previously called "selectlist" but they seem to have pivoted to alter/enhance the select element instead):

https://open-ui.org/components/selectlist/

alexfromapex · 2 years ago
Wish browsers would start shipping a sensible multi-select. There’s one now but it’s not user-friendly enough IMO.
jareklupinski · 2 years ago
i built one a bit ago using an event (onselect or onchange?) handler on a regular dropdown that, when you click on an item, the handler removes that element from the dropdown options, and adds it to another ul/li list under the dropdown, with a little X to reverse the process

select2 does something similar but yea it's weird this isn't a built-in

maybe a dropdown with checklists?

config_yml · 2 years ago
> maybe a dropdown with checklists?

That's builtin with <select multiple> but it's only usable on mobile.

asddubs · 2 years ago
And one with drag and drop reordering. or at least some form element that allows drag and drop reordering (ideally of arbitrary markup blocks)
OJFord · 2 years ago
TFA mentions `optgroup` too, wouldn't it make more sense to use that and style it similarly? Especially if `hr`-in-`select` is only going to work in Safari anyway(?).
chrisb · 2 years ago
The article isn't completely clear; but hr-in-select is standardized [0] - and it definitely works in the Firefox v122.0 I'm browsing with.

[0] https://html.spec.whatwg.org/multipage/form-elements.html#th... (see the "Content model" line)

Deleted Comment

OJFord · 2 years ago
Pfft I'm an idiot - I'm reading from (and tried it out with) Firefox too!
vinnymac · 2 years ago
Not to mention the user experience for an optgroup on mobile is vastly superior as a sheet rather than a popover.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/se...

For those without iOS, see an example here: https://ibb.co/DkN16Gc

Pesthuf · 2 years ago
<select multiple> on mobile devices is so good - why don't the finally improve the implementations on the desktop as well? The arcane 90s UI paradigm it currently uses everywhere just doesn't work.

And please, just give us an attribute that adds a search bar... I don't want to use 30 KB of JavaScript just to have selects that feel like they're from this millennium, especially since those then don't work too well on mobile…

crazygringo · 2 years ago
Funny, it looks way better on mobile than it does on desktop [1].

On desktop (Chrome on Mac) each optgroup label is just a disabled item, and then its options are indented menu items below it.

It looks totally hacky -- the name of a group shouldn't seem like "disabled" option, nor are indentations in menu items an established convention.

That sheet on iOS is perfectly intuitive, however.

[1] Link to page section with demo: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/se...

shiomiru · 2 years ago
Agreed, this just looks like a non-accessible <optgroup> alternative and feels like a step backwards. I fear authors will now use hr instead of properly grouping their elements, to the detriment of screen reader users.

Why not just make horizontal rules between optgroups the default?

lapcat · 2 years ago
Optgroup has a mandatory label attribute.
xp84 · 2 years ago
Sadly, this is all academic because in all commercial work, “designers” demand that you reimplement SELECTs to make them look a very, very specific way “consistently across every OS, for our branding’s sake,” leading to devs implementing them as a soup of 42 nested DIVs, an SVG or two, and 12 event handlers, and they still don’t act right when the dropdown doesn’t have enough space below it in the viewport.
uses · 2 years ago
i had no idea <select multiple> existed. it works great on my ipad and has great browser support.

https://caniuse.com/mdn-html_elements_select_multiple

bdcravens · 2 years ago
It's always been there, but for traditional browsers, it was tedious: Ctrl/Cmd + click. Many non-power users found it tricky or didn't know about it, so we all more or less settled on checkboxes as a UX standard.
ErneX · 2 years ago
teddyh · 2 years ago
I believe the canonical spec for HTML 2.0 is actually RFC 1866: <https://www.rfc-editor.org/rfc/rfc1866#section-8.1.3>
zerocrates · 2 years ago
What's the reasoning for allowing select to have hr children but not optgroup? It doesn't seem like it would be any more problematic but I imagine I'm missing some relevant issue.
vinnymac · 2 years ago
> You could still see it by manipulating the DOM or using XML, but apart from a couple of experts nobody knew.

Except for all the users who were frustrated by the change. Most users wouldn’t even know who to report this to, even if they noticed it at all. They may chalk up the issue to the new computer or phone they purchased in the last two decades.

lapcat · 2 years ago
For me the problem is that iOS already adds horizontal rules between all select options, so the new feature doesn't make any sense there, and I can't share code between Mac and iOS.

I wonder if anyone on the WebKit team looked at the blog post example in Mobile Safari?

chrisoverzero · 2 years ago
Are you under the mistaken impression that this feature is already implemented in mobile Safari on iOS 17.3? It isn’t.

On iOS 17.4, you’ll be able to see that the divider is thicker and obvious. Long-press on the Safari address bar for an illustrative example. See the gap between “Voice Search” and “Move to Tab Group”?

lapcat · 2 years ago
> Are you under the mistaken impression that this feature is already implemented in mobile Safari on iOS 17.3?

The blog post didn't mention iOS at all. I'm glad to hear that the feature is coming in the future, though it's strange that the blog post didn't mention it, and also strange that they didn't implement it in 17.0 at the same time as desktop.

vinnymac · 2 years ago
For those without an iOS device see this example: https://ibb.co/N7Mw4dW
eyelidlessness · 2 years ago
It doesn’t render an extra separator on iOS, so you should be able to use the same markup.
lapcat · 2 years ago
I think you're missing the point. The redundancy of the <hr> on iOS means that on iOS the <hr> doesn't serve its purpose of separating the options.