by mihaic · 4y ago · 0 comments
There are too many needlessly reimplemented components, but anyone that has ever needed to style a <select> to make it look in line with any modern design quickly reached desperation.
I'd love to be able to use standard components everywhere, but most of my users care if my website looks like it's from 2004.
Example, a multi-select, see https://jsfiddle.net/z0Ltxh47/1/ :
Usability is bad because I can't select multiple non-consecutive items by using just my mouse. It's very narrow by default, and doesn't allow me to resize.
API: Your typical HTMLInputElement.value doesn't give me all the selected values. I need to map the .selectedValues to their values, or innerText if no value exist. Horrific.
Accesibility: At least in Firefox, using ctrl+arrows to be able to focus on elements to select them do not render any focus targets. In Chrome, the contrast is not there.
Don't even get me even started with the date/time-picker.
It is a hard concept that isn't completely solved by any of the standard GUI widgets.
A multi-select drop down is just solving the problem of a checkbox list being too long, or not what the designer wants it to look like. The most clear UI for this input type is a set of checkboxes in my opinion. Same for a single item select and radio buttons.
Drop downs have a lot of caveats, and unique compositions in the wild, so many of them are inaccesible and it's essentially just because someone wanted it to look pretty. I think that is bad software.
I find that I often have half second hangups due to not remembering if in select mode or not.
Much prefer the "Hold shift/ctrl" model used often in file managers.
Depending on the application, sometimes to fix such problems, you need to reimplement the component in js or you start won't fix'ing tickets.
So articles like this really underestimate the problems with the existing controls and the lack of some.
- Multi-select by Ctrl+clicking on other items I want selected. (works)
- Shift-click to expands the selection linearly from the focus (works)
- Select one item, then Shift+Up/Down arrows to expand the selection. (Works)
I bet a custom control would be missing most of that behaviour as well.
Mind you, those affordances are completely unknown to most users. I bet if you asked most users (even developers) how to select multiple items in that control, 9/10 would struggle. The input control doesn't make its affordances obvious at all.
So in all, I'm confused what the browser vendors expect people to do here. I'd love to use the built in controls. But as others have said, they're often ugly, they confuse people, their APIs are a mess and they're difficult to style.
You can still write one as an add-on for your browser and help others or use it as poc for a ticket to the browser vendor.
...And then to make that drop down pretty, and the checkboxes look neat, we'll set their opacity to 0 and remove pointer events, use CSS to style the label and set a nice looking tick using the 'before' content, which changes when the checkbox is selected... And oh, there again!
and then it gets complicated very quickly: https://jsfiddle.net/wdqjyvsu/1/
You also have still undiscovered problems: How to let people filter the options if you have lots of them (and don't say ctrl+f because it doesn't restrict the search within the element)? What about lazy-loading if you have lots and lots and lots of them?
Usability is not improved, it takes too much space now. API is even worse. Accessibility is improved contrast-wise but all the tabbing is not very friendly, and try using that with a screen-reader. It takes ages to make a selection.
I'm guessing you're trying to argue that something like a pill autocompleter is more appropriate for specific use cases (e.g. the `to:` field in email clients). And sure, sometimes some controls are better suited than others depending on the use case, but that doesn't necessarily mean that it's impossible to implement similarly complex controls by leveraging standard controls as opposed to reinventing headless behaviors on top of div soup[0]
<details> is pretty easy to style and shouldn’t be to complicated to add extra features like filter fields by search etc.
Well you can with ctrl-click. A well hidden feature though.
(and I think this is unfortunate. I wish developers didn't attempt to replace my browser's perfectly fine-looking, accessible checkboxes by their own often ugly custom implementations for instance. And I'm not hating on web devs, I'm one of them)
XUL [1] seemed like a good idea as a basis for building native-looking web applications. It's too bad it has been abandoned.
Didn't XUL do roughly what React Native, and other similar frameworks, do today?
edit I see that XUL did its own rendering rather than using native widgets, but the overall goal seems about the same.
> The purpose of Open UI to the web platform is to allow web developers to style and extend built-in web UI controls, such as <select> dropdowns, checkboxes, radio buttons, and date/color pickers.
Their current thinking is to cook a new element, <selectmenu>. Here's a demo of styling it in an experimental version of Chrome. https://www.youtube.com/watch?v=IjHnmaquifM
(They went with a new element <selectmenu> instead of <select styleable=true>, but there's still an ongoing debate about that, and/or how to polyfill it.)
You're declaring this based on what, exactly?
And as a developer I often need to argue with the designer that please just don't use dropdown on mobile ui when there are many items. That is just a torture for a phone user.
And sometimes I even need to add hidden area to the ui. Because the controls are way too tiny to click.
Usability are not really in their mind., Or probably it is just a bad designer.
And I get where they're coming from.
At the same time... native browser controls work, they don't require maintenance, they don't add to the bundle size, or have complex version inter-dependencies.
Maybe it's time to rethink frontend. Maybe what we write should be designed to work with the standard HTML controls.
(Or maybe it's time for me to go back to the backend and play with database, because I feel increasingly out of touch).
and this is by design, web as a platform is pretty much owned by tech giants like google and apple who have a financial interest in keeping the web from becoming a rich platform which would cut into their app store hegemony.
ironic when you consider iphone and the html 5 back story. in some respects microsoft with IE back in the days was more interested in developing the web as a platform but also saw the web as something they could monopolise whereas now apple takes a more nuanced but just as much devious approach.
Google is guilty of plenty of things, but holding back the web as a first rate development platform is not one of them, and I think the blame falls squarely on Apple's shoulders here.
Just look at what you can do with a PWA on Android. Most importantly, unlike on iOS, you can receive push notifications. But you can also do things like ship a PWA directly to the Play Store, access all sorts of native browser libraries like Bluetooth support and Add to Home Screen.
If you look at non-gaming apps, I'd estimate about 90% of them could be straightforwardly implemented as PWAs. The reason they're not is due to deliberate decisions by Apple not to support the tech that would make that possible, like push notifications.
Then don't make it look "in line with any modern design". Make it look like an HTML select tag, because that's what it is.
Functionality should (nearly always) trump prettification. (Especially when the results are pretty anyway).
If more powerful browser components would be available then designers would be happy to just style those, and functionality and accessibility would still be fine.
[1] graphic design is a completely legitimate field and a good way to get into UI design, but if that's all you've got, you still have quite a way to go
Take a look at the search page.
I don't believe there are many designers who are interested in creating experiences with poor usability, thus my point about ignorance and not understanding the tradeoff they are making. On "incompetence", if a designer understands fully that they are creating something that will be less useable and accessible for the sake of aesthetics they have earned the label. To take the HN search page as an example, the filters can't be interacted with via keybord or screen reader. When it's your job to help users solve problems and you have made it knowingly harder to do that, I don't see how that's competent.
Luckily, it has been my experience that in most cases(including my own) the former, rather than the latter, is at play.
It's true, and it really shouldn't be as controversial an opinion as it apparently is.
That would go a long way, but doesn't support more complex UI like checkboxes in the dropdown (for a compact multiselect component), a treeview instead of a listbox (including checkbox support), and highlighting parts of option text for things like autocomplete (with the ability to filter based on what's being typed).
It would also be useful to know if the listbox is being displayed above or below the select, so with a rounded border, you can style both the select input and listbox to have a flat edge on the top or bottom accordingly.
For checkboxes, it should be possible to theme them more easily, including: 1. border width, colour, and radius for the box; 2. a graphic or unicode character for the checked and mixed states; 3. optionally an image for the entire checkbox.
No one has ever, in the history of software, NEEDED to style a <select>. You want to style a select. Your users don't give a toss.