Before going any further, know this:
There's a patch of comments - #175-#235 - that may be a bit confusing as some of what was discussed spun off into a different issue: #3076171: Provide a new library to replace jQuery UI autocomplete
Anything in this issue that specifically discusses replacing jQueryUI with Awesomplete is no longer relevant to this issue and can be ignored. Everything else particularly the library evaluations, are still fully relevant. The desired improvements to select elements will need to be accomplished with a different library than what is used for autocomplete.
In other words: The stuff about Awesomplete is not relevant to this issue, but everything else is. . This is about improving the UX of select lists.
Problem/Motivation
Improve usability and accessibility of long select lists and autocomplete tagging widgets.
Proposed resolution
- Evaluate possible libraries
- Create a pro / con list and required feature list for the library candidates, for example
- Code style
- Maturity
- Responsiveness
- Accessibility
- UX
- UI
- Modularity
- AJAX support
- Single / multi select
- Filter search
- ...
- Choose the best matching library for Drupal's needs.
Libraries evaluated so far
- https://github.com/jshjohnson/Choices Evaluation (#189)
- https://harvesthq.github.io/chosen/ Evaluation (#194)
- https://github.com/Mobius1/Selectr Evaluation (#195)
- https://github.com/alphagov/accessible-autocomplete (prototype at #182, great accessibility but not considered as it does not support select/multiselect It is strictly for providing suggestions to single-value text fields)
- https://github.com/HemantNegi/jquery.sumoselect Evaluation (#201)
- http://ivaynberg.github.io/select2 (of which https://github.com/woocommerce/selectwoo is a fork of, created to improve accessibility) Evalulation (#193)
- Custom library based on https://react-select.com Evaluation (#200)
- https://selectize.github.io/selectize.js/ Evaluation (#199)
- https://github.com/github/auto-complete-element Evaluation (#222)
(disregard the Awsomplete evaluations - it is a great library, just not relevant to this issue)
Remaining tasks
- Determine specific requirements for new functionality
- Compare against the libraries reviewed so far, and evaluate additional ones when discovered
- Confirm the desired replacement is sufficiently accessible
User interface changes
Yes.
API changes
Yes.
Comment | File | Size | Author |
---|---|---|---|
#223 | awesomplete-prototype.patch | 75.81 KB | bnjmnm |
Comments
Comment #1
mgiffordThis looks sharp. Works as expected without a mouse which is great.
I've only looked at this with VoiceOver, but there are some issues here. I've asked for a blind user to review this and provide better feedback. As a sighted person, my use of a screen reader is pretty basic.
When I first go to the screen I'm simply informed that there is an English pop up button:
I go down and I get all 94 results:
I enter in a key (not that there is any indication to me that this would have any impact - it isn't very discoverable) and I get a summary of results. It would be nice if it were able to read that shortened list of results.
When one option has been selected that isn't english and you go back to edit the dropdown:
When you've selected one result.
Comment #2
mgiffordI added some elements to my taxonomy, then went http://sb8acaa3c676552c.s3.simplytest.me/node/add/article
I've attached the screenshots below, but not fleshed out the descriptions. The file names kinda illustrate the problems.
It works but also needs work.
Comment #3
Bojhan CreditAttribution: Bojhan commentedOeeh, nice. Looking forward to the A11y review
Comment #4
mgiffordI've uploaded so many images I can't find the patch anymore.
I am going to have to write up what it should be and then see what we can do to make it that way. We do need to have some action points.
Accessibility is probably going to be the major hurdle for this patch (and I'm not sure whether it's for Select2 or the implementation). I do hope we can git it in though as it's a nice feature.
Comment #5
mgiffordI'm going to write out what should happen for accessibility:
A) On Choose a language
1) Rather than saying "English pop up button" it should say "Language selection pop up. English selected."
2) On entering the pop up, the user should be told "94 results are available, use up and down arrow keys to navigate" it should say "To choose a language, enter the first few characters. 94 results are currently available."
3) When a key is pressed the user should be told that the list changed. Rather than "6 results are available, use up and down arrow keys to navigate." -- it would be nice if it was more consistent with autocomplete and would read the list.
4) If there is only one result, it should read the result. "One result is available, press enter to select it." is a pretty useless description. In my example it should read something like "Bosanski selected, press enter to save and continue."
I can't see the source code to see how viable that actually is.
Comment #6
mgiffordB) With the taxonomy term, it is important to provide more context as this will be very confusing.
1) When you first tab to the form you're told "Tags edit text list 1 item" but really should be told that this is an empty form and that they should start typing to either get a list of previously selected tags or to enter a new tag.
2) On hitting f, I'm told that "4 results are available, use up and down arrow keys to navigate" it would be nice if it were consistent with autocomplete right now and list the selection.
3) If there's already a tag selected, the count is off. "4 results are available" seems wrong given there are 3 in the list:
4) Frog is pronounced when selected:
5) The tags have a nice description field which is available but it isn't read to the screen reader as it's done as a title to the input form. It says "Please enter 1 or more character"
Comment #7
oushen CreditAttribution: oushen commentedHi. When D8 go to beta release, I will port Select2 module to D8 and we can use it for tags (and other taxonomy ref) fields, autocomplete fields and other.
Comment #8
nod_Thanks oushen, any chance you can help out this patch? I'd rather have that in core in 8.1.0 if we can instead of contrib. That way we'd make sure the integration is accessible and that many more other contrib modules can use it (like rules maybe).
Comment #9
droplet CreditAttribution: droplet commentedget the patch back.
Comment #10
mgiffordI had to search for a cached version of the page to get the patch:
https://www.drupal.org/files/issues/core-js-select2.patch
Comment #11
attiks CreditAttribution: attiks commentedThe summary says to use it for taxonomy, why don't we use it for multiple selects as well?
Comment #12
mgiffordI think @nod_ was primarily developing this as a use case to see what problems we'd run into.
There are a few accessibility problems with it at this point. I've tried to articulate how they should be improved.
Comment #13
oushen CreditAttribution: oushen commentedattiks, at this week I will publish dev release of Select2 module for D8, with this module you can use it for all select form elements, autocomplete fields and define select2 options for custom elements by Forms API.
Comment #14
attiks CreditAttribution: attiks commented#13 Cool
Comment #15
Bojhan CreditAttribution: Bojhan commentedAlright, so this greatly impacts i18n - who made a major follow up.
Comment #16
tkoleary CreditAttribution: tkoleary commented+1 to that!
Comment #17
tkoleary CreditAttribution: tkoleary commented@mgifford @nod:
If "choose language" is not being read it's because the "aria labeledby" attribute is missing I think.
Comment #18
tkoleary CreditAttribution: tkoleary commentedAmen to that
Comment #19
tkoleary CreditAttribution: tkoleary commented@mgifford
The "please enter one character" issue also looks like aria labeledby is missing
Comment #20
mgiffordWe can add aria-labelledby to the 'Choose language' title in core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php
I think the "please enter one character" is a vendor issue though that's part of Select2. Not that we can't change that, but it is a change for stuff up-stream.
With any dynamic tool like Select2 WAI-ARIA is going to need to be added to add the required semantics.
Drupal.announce() is also worth looking at https://www.drupal.org/node/2014521
Comment #21
tkoleary CreditAttribution: tkoleary commentedYes, but having said that, from my research the library already has more aria roles natively than any other and if we make that more robust it would be more responsible for us to add them upstream submitting pull requests to Select2 on github. That way others can benefit as well.
Comment #22
mgiffordI'm totally onboard with providing patches to Select2 and pushing them upstream. I think they'd be open and everyone would benefit.
I'm just not a JS person so won't be leading the way in developing the patch.
Comment #23
XanoCan you please update the issue summary so it includes the reasons for adding this, which problems it solves, etc?
Also, this looks like Chosen. Do they really do similar things and if so, how do they differ?
Comment #24
mgiffordTook a quick look for comparisons of Select2 vs Chosen.
They do pretty similar things from what I can tell.
Comment #25
Bojhan CreditAttribution: Bojhan commentedIt is worthwhile to look at Kevin his evaluation at https://docs.google.com/spreadsheets/d/1vifOGL_4wgOl6sy2Os59k24saIHvwFFQ...
Comment #26
andypostThis would be really useful for new UI for related help topics #2351991-55: Add a config entity for a configurable, topic-based help system
Comment #27
andypostComment #28
andypostwrong issue
Comment #29
droplet CreditAttribution: droplet commentedComment #6: 3,
I sent a patch to upstream and it's merged now. https://github.com/ivaynberg/select2/pull/2726
Comment #30
Wim LeersThis would also finally solve the many huge problems (UX-wise and otherwise) with jQuery UI Autocomplete explained at #675446-271: Use jQuery UI Autocomplete. Great work here :)
Comment #31
tkoleary CreditAttribution: tkoleary commented@Nod
Given the upstream changes to Select2 for a11y are we unblocked on rolling a patch?
Comment #32
mgiffordIs this going to have to get bumped to 8.1.x.?
Is there any chance that a patch will get into 8.0.x for this?
Comment #33
Bojhan CreditAttribution: Bojhan commentedComment #34
mgiffordComment #35
YesCT CreditAttribution: YesCT commentedI put the templates in the summary, but there are details I'm not sure of.
What is the motivation here?
Why is this a feature request?
Could this qualify for beta under "prioritized change"?
Comment #36
YesCT CreditAttribution: YesCT commentedComment #37
amateescu CreditAttribution: amateescu commentedI think it's very important to get this into 8.0.0 for multiple reasons:
#1271622-29: Seek a better autocomplete replacement for core (jQuery TokenInput / Select2 / Typeahead.js by Twitter)
#1271622-44: Seek a better autocomplete replacement for core (jQuery TokenInput / Select2 / Typeahead.js by Twitter)
Also note that Entity reference is very likely to replace the taxonomy term reference field in D8 so the last point outlined above is going to get in everyone's face soon enough.
I started with @nod_'s patch referenced in #10 but I'm not sure that creating one-off libraries for every select element that wants to use Select2 is a good long term strategy, and we should rather aim for a much better DX by integrating it right into Form API's select element via an optional #select2 property.
Haven't touched the autocomplete bits yet but this patch shows how I envision the Form API integration. I also added the #select2 option in two more places, the timezone selectors, just to demonstrate how easy it should be for everyone to use it.
Comment #38
jibranComment out code.
Comment #39
Wim LeersWhy on
\Drupal\Core\Render\Element\FormElement
and not on\Drupal\Core\Render\Element\Select
?AFAIK there is no other element that could use it?
Comment #40
amateescu CreditAttribution: amateescu commentedText elements that might have a different purpose than autocomplete can use it too, so why not give them the possibility? :)
Comment #41
amateescu CreditAttribution: amateescu commentedHere's the complete integration with Drupal's autocomplete requirements, with proper markup escaping and all that.
The only thing left that still needs work is to provide support for our
"term with, comma"
syntax, which is not supported by Select2 at all. Every time this question comes up on github or other support forums, people just say to use "|" as a delimiter, but I don't think we have that luxury of choice in Drupal so we'll need to provide our own tokenizer function. I looked a bit at that code but I hope @nod_ can help out here since he's, well.. more familiar with JS :)Comment #43
amateescu CreditAttribution: amateescu commentedFixed that last test. Let's see what @nod_ thinks about #41.
Comment #44
jibranCan we have a core only patch *pretty please*?
Comment #45
amateescu CreditAttribution: amateescu commentedIt's in #41?
Comment #46
jibranpardon my ignorance patch looks good to me.
Comment #47
xjmLet's get the beta evaluation updated to be more than boilerplate? :) It would be really valuable to summarize in that table why this is major, what the improvements for accessibility and such are, and what the disruption would be within core, for contrib, etc. :)
The diffstat for the core-only patch in #41 is nice.
Comment #48
xjmE.g. this change in the array structure is a (reasonably small) disruption for contrib. Etc.
Comment #49
amateescu CreditAttribution: amateescu commentedImproved the entire IS a bit, I hope it's more clear now :)
Comment #50
attiks CreditAttribution: attiks commented#48 does this mean that the keys need to be changed depending on the fact that you use select2?
Ex: if I remove the "'#select2' => TRUE" from a select, will this break the code?
Comment #51
amateescu CreditAttribution: amateescu commented@attiks, the keys have to be changed everywhere. But that's only about the autocomplete API, not about using Select2 in regular select elements.
Comment #52
nod_I don't think we need to change the keys, the naming makes more sense as it is now and it's trivial to map that on the JS side.
Comment #53
amateescu CreditAttribution: amateescu commentedI changed them because we also did it when we switched to jQuery UI autocomplete in #675446: Use jQuery UI Autocomplete, so I thought we want to follow the Select2 defaults. I don't have any strong opinion about it though :)
Comment #54
amateescu CreditAttribution: amateescu commentedI thought about it some more and I agree that the
value => label
combination makes more sense thanid => text
, so let's drop the slight API change and just keep the huge UX improvement :)Comment #55
aspilicious CreditAttribution: aspilicious commentedI WANT this patch so I tested it but found some problems.
- tags with spaces don't get recognised
- When editing the same node nothing gets recognised
- Why is timezone a select 2 field and country not?
- Can there be multiple authors? That's confusing. After the first author the autocomplete doesn't work anyway.
Comment #56
amateescu CreditAttribution: amateescu commented@aspilicious, thanks for the review!
That's already mentioned in #41 :)
Yeah, the country selector is long enough to need the Select2 widget. Added.
Fixed.
Comment #57
nod_Quick review, I'm looking at the tag splitting thing.
Dependencies are not right, the misc file should be in drupal.autocomplete. Not here since it'd make select2 depend on core/drupal and core/drupalSettings.
Default should be an object, otherwise the JSON will end up as [], not {}.
We might want to expose that in drupalSettings for people to be able to change it globally, not just with data attributes.
Set a data attribute instead of a class and use it to select elements please.
data-drupal-autocomplete
would work.?
Comment #58
amateescu CreditAttribution: amateescu commented@nod_, I was looking into the tokenizer thing as well and I got it mostly working, here's my WIP diff.
Comment #59
amateescu CreditAttribution: amateescu commentedQuick update for the review in #57:
Not sure that's correct, that code is just registering Select2 into our library system, and it's only dependency is on jQuery. Since we've now integrated Select2 into Form API, this is not tied to autocomplete anymore.
I don't know what's the "right way" to do this. Do we usually expose stuff in drupalSettings from inside a js file?
Comment #60
nod_This file is the problem:
misc/select2.js: {}
Look at all our other vendor libs, they don't have extra Drupal dependencies (this file will crash JS because Drupal isn't defined if you load only core/select2).Here is the tokenizer thing with some improvments in splitValues. Based on #56.
Comment #61
amateescu CreditAttribution: amateescu commentedFinally understood what @nod_ meant with the separate library. Fixed that and incorporated the tokenizer from #60 into the main patch.
Comment #62
aspilicious CreditAttribution: aspilicious commentedTag autocompletion still has issues. I made two tags:
"Some tag", "a new tag"
When editing the node you get 1 merged tag: "some tag, a new tag". The tag list in the backend looks ok, so it's a js thingie.
Comment #63
nod_You can laugh at me:
Then it works.
Comment #64
amateescu CreditAttribution: amateescu commented/me giggles at @nod_ :D
The fix from #63 fixes the problem mentioned by @aspilicious, but there's still one small issue: you can never remove a tag which contains a comma :) It is removed visually from the input element but when you save the node, it's still there, sometimes even duplicated.
Comment #65
quicksketchThis looks like a great direction.
Looking at the library and the patch, what approach should be used to bring consistency to non-Select2 select lists and Select2-enabled select lists? @aspilicious's image in #55 shows the differences pretty clearly. I'm guessing the default styling for Select2 would be left in place (considering there are no "skins") and the theme would take on the responsibility of styling them individually (as Seven theme styles select lists already).
Comment #66
amateescu CreditAttribution: amateescu commentedI'm not sure that the Seven theme styles select lists already. At least on FIrefox/Chrome on Kubuntu, the select lists look like the OS ones, and I don't see any select-specific code in firebug.
My proposal for styling is to use the Seven style guide, so even if Select2-enabled select elements won't look like the regular ones, at least they'll be consistent with the rest of the theme. We already have a dedicated issue for this: #2318665: Implement the dropdown menu component styling into the autocomplete widget, but I'm not opposed to doing that work here.
Here's a reroll for current HEAD + the small fix from #63 (Drupal only patch for review is in #61).
@nod_, do you have some time to look into that small (last) issue with the new tokenizer found in #64?
Comment #67
LewisNymanIt does, but only on Webkit because cross browser support for styling the native
element is poor. #2207391: Style select elements in Webkit only
Comment #68
LewisNymanI have to say this is looking very good. I recommend we stick with the default library styling, and work on the Seven styling in #2318665: Implement the dropdown menu component styling into the autocomplete widget
Comment #69
nod_Umm looks like a new version of select2 got out (in beta still), the catch is that select 2 can't work with inputs anymore, it expect a select element (it makes sense given the lib name). See Select2 v4 beta. The consequence for us is that the current tag input field for taxonomy won't work with the new version of select2. That's a bummer.
We can transform tag input in a select with JS (progressive enhencement and all) but the data sent to the server will be different, unless we serialize the values from select2 in the input on submit.
Comment #70
amateescu CreditAttribution: amateescu commentedYes, I saw the new version of the library and that it contains quite a few things that break our current integration, but that doesn't mean we should drop this issue, I hope?
This doesn't look like an unsolvable problem :)
Comment #71
LewisNymanhmm, I don't understand. How would you add a new value that doesn't exist as an option in the select dropdown? Or is that now outside of the use case of Select2?
Comment #72
amateescu CreditAttribution: amateescu commented@LewisNyman, a select dropdown is needed just as the initial element, adding new values / tagging works just like before: https://select2.github.io/examples.html#tags
Comment #73
Wim LeersIndeed, looks like we can work with Select2 version 4 just fine; we'll just have to change
#type => input
to#type => select
.Comment #74
LewisNymanI think a select element feels like a much better JS fallback than a blank text input.
Comment #75
Wim Leers#74: except that you can type in a blank
input[type=text]
, but the<select>
Select2 uses would be empty in our case, since free tagging in Drupal allows for thousands of terms to be created, not all of which can be listed. Disable JS and look at https://select2.github.io/examples.html#data-ajax for a more accurate fallback UX.And that is actually a great point: the no-JS experience. Do we even still care about that? E.g. dropbuttons are also completely broken without JS.
Comment #76
quicksketchI just spent a day trying to upgrade the D7 Select2 module to support the new 4.0.0 version of the library. It *really* doesn't like working with input fields. Dropping support for (hidden) inputs is actually listed as a feature of the new version: https://select2.github.io/announcements-4.0.html#hidden-input
In trying to use it on input textfields, Select2 simply has no support whatsoever now. It actually tries to embed
<option>
tags inside of the textfield<input>
element. The only hope we'd have is doing as Wim suggested and replace the textfields with select elements.I don't know if this is going to be a suitable replacement for autocomplete text fields. A select list isn't going to be the right element when dealing with large lists, which is pretty much any situation we have autocomplete currently: author name, term tags, the search on api.drupal.org, etc.
The whole situation is disappointing. The "best" library for autocomplete basically doesn't want to deal with autocomplete and wants to focus exclusively on replacing select list elements. I suppose it shouldn't be too surprising, considering their past claims that autocomplete/type-ahead is outside the scope of their goals: https://github.com/select2/select2/issues/17.
Comment #77
aspilicious CreditAttribution: aspilicious commentedWe have a site with more than 6000 tags and counting (since september 2014). We can't use select fields for those in combination with select2 because it's nearly impossible to render.
Making tags a select field would introduce severe performance issues.
As I do see the advantage for 95% of the use cases I would like to have a fallback to the current behaviour. But that would be hard because one widget is a textfield and the other a select widget :s
Damn...
Can't we fund a JS genius to make a drupalSelect fork of select2? XD
Comment #78
droplet CreditAttribution: droplet commented@#77,
You won't tagging 6k tags in ONE node ??
Technically, we can rendering select list in client side (converting from input).
see patch in #66, it still making a lot of changes to JS/PHP code. It's a sign that D8 still having bad Autocomplete API architecture in CORE. I think we need to shape it better API to adopt different JS libs for future developers (without CORE JS & PHP patching).
Comment #79
attiks CreditAttribution: attiks commented#78 We have similar (and bigger) vocabularies as @aspilicious mentioned in #77, outputting a select list is not going to be an option. Most of the entities are tagged with multiple terms.
Dream scenario:
Have a widget that renders the right HTML depending on the amount of data and attaches the right libraries.
For example (boundaries to be defined in config):
10 or less options and without tagging: output select, no select2
200 or less options and without tagging: output select, use select 2
200 or less options and with tagging: output text, use select 2
201 or more options and without tagging: output empty select, use select 2 + ajax
201 or more options and with tagging: output input, use select 2 + ajax
Really nice to have: Add support for hierarchical vocabularies as well, so site user can select parent term as well and they are rendered as nested.
Comment #80
amateescu CreditAttribution: amateescu commentedWhoa, hold on there.. isn't #72 clear enough in this regard? :)
#73 is wrong, there's no change needed on the PHP side (at least for the element declaration), we just need to convert the text input into a select before Select2 is initialized on that element.
Comment #81
attiks CreditAttribution: attiks commented#80 I'm probably missing something, but what is the policy for non js browsers, 'cos if we output a select for free tagging it will not work without javascript. Unless we are converting the input to a select using javascript?
Comment #82
amateescu CreditAttribution: amateescu commentedBingo! :) Just as @nod_ said in #69 when the discussion about the new version of Select2 started.
Comment #83
attiks CreditAttribution: attiks commentedComment #84
attiks CreditAttribution: attiks commented#82 I've updated the IS, but by reading the comments the API change is no longer needed?
Comment #85
aspilicious CreditAttribution: aspilicious commentedI'm a JS noob, so I can't say anything useful, but I think when it's done we need to manual test this with 1000+ tags to see if it has any effect. Just to be sure. I'm always ready for doing that when needed.
It will gain me lots of credits with the UX designers at work ;)
Comment #86
quicksketchSorry, yeah I kicked off the discussion in the wrong direction there. We can convert the textfield to a select *with JS*, then run Select2 on the new select list field we just created. However, that means we're going to have to adopt a lot of custom code to deal with converting a textfield to a select list. You'd need to account for single/multiple values, parsing the input field, converting it to a select list with the entered options selected. Then run Select2 on the resulting new select field and load the results via AJAX like we had been doing before. Before the values are submitted to the server, you have to convert these values *back* into a input so it would all come in as a single value in POST. A select list will send multiple values as an array.
Rather than attempt to revert the select back to input, we'd probably find it easier to maintain the original input on the page, and update it as the select list is updated.
So in summary, to use Select2:
- PHP outputs a textfield onto the page.
- Hide the original textfield and create a select list "copy" of the field with JS
- Apply Select2 to the select list, load results via AJAX
- On value change, update the original textfield.
- On POST, the server gets the value from the original field. The select element we could leave with no name attribute, so it would be nothing but a client-side widget for manipulating the hidden field.
So basically we'd re-implement the functionality that was removed from Select2 to support hidden fields.
I don't know... it's possible but doesn't seem right.
Comment #87
Wim Leers#76/#77: did you look at how https://select2.github.io/examples.html#data-ajax (that specific linked example) works? It works with an empty
<select>
, for which<option>
s are generated by Select2.#86: that sounds very doable? But I agree that it's very unfortunate that the
input[type=text]
-based autocomplete use case is no longer directly supported by Select2. I really wonder why the author did that? After all, what Select2 presents UI-wise resembles ainput[type=text]
much more cosely than a<select>
, so even in that regards it's a puzzling change. The removal of ainput[type=hidden]
dependency makes sense to me, the removal ofinput[type=text]
not so much.Does anybody of us know the Select2 author? Or has any of us followed its development closely? If so, then perhaps we can start a conversation with the author? One of us should reach out to the author IMO; Drupal 8 would be one of the most prominent users of Select2, I imagine, so perhaps he'd be willing to add this back for us. Or perhaps he'll manage to convince us of his reasoning :)
Comment #88
nod_Reason was code simplification. it's easier to deal with options elements than splitting a string, also the return is cleaner for the backend, getting an array of split values is better than a string of values to split. It's in the github queue somewhere.
Not sure how messy it'd be to add back input support, but I guess we should reach out in any case.
Comment #89
kevin-brown CreditAttribution: kevin-brown commentedI'm the maintainer of Select2, and I'm interested in working together to fix the current lack-of-text-input issue.
I removed support for hidden inputs (
<input type="hidden">
) because there was no non-js fallback. Non-js users would be presented with absolutely nothing, and most likely any validation would be failing (pretty silently) because of that. All in all, it wouldn't be a great user experience, and it was something I wanted to avoid. Now, I didn't realize that people were using a text input as the fallback until about a week ago, and because of that much of the code is expecting a<select>
, which is great because we don't have to special case that much.The problem with the old implementation largely revolved around
initSelection
, a badly named function that handled the job of converting thevalue
attribute to a set of data objects. I'm interested in working together to figure out what would need to be done to have Select2 function as an autocomplete for Drupal, but my knowledge of how the Drupal internals work is very limited.We are tracking this issue at https://github.com/select2/select2/issues/3022 as well.
Comment #90
Wim LeersThat's awesome news! Thank you!
Basically, all there is to know is this:
foo, bar, baz
-> "baz" is being autocompleted.Some Person, "Leers, Wim", Another Person
has 3 tags: "Some Person", "Leers, Wim" and "Another Person".(This behavior would probably need to be implemented on the Drupal side, which is exactly what @amateescu did in #66, until @nod_ remarked in #69 that Select2 version 4 was about to be released, and this issue kind of got stuck on what to do now that Select2 no longer natively supports
input[type=text]
. In other words: you probably wouldn't even have to care, as long as we can still make it work just like we did for Select2 version 3.)input[type=text]
with some UI additions for autocompletion that helped the user get data in there ininput[type=]text]
faster and more easily — hence degrading "gracefully" to a very unhelpful, autocompleteless, mindblowingly simple UI: the plaininput[type=text]
.Comment #91
nod_Thanks for the offer kevin-brown. Hopefully we can work this out :)
Comment #92
Bojhan CreditAttribution: Bojhan commentedComment #93
Dom. CreditAttribution: Dom. commentedAlso maintainer of Search Autocomplete interested in helping if needed : #2442699: UX improvment on autocompletion
Comment #94
Dom. CreditAttribution: Dom. commentedComment #97
njbarrett CreditAttribution: njbarrett commentedNow there's a release candidate for Select2 4.0, do you think now is a good time to create a new patch for this issue?
Comment #98
Wim LeersIndeed, more than a month ago, the solution on the Select2 side was merged: https://github.com/select2/select2/issues/3022#event-243644862, https://github.com/select2/select2/pull/3051.
Comment #99
quicksketchSelect2 4.0.0 was released about 2 week ago. Looks like this issue back on. ;)
Comment #100
joelpittetTagging frontend for sprint.
Comment #101
mgiffordShould we bump this to 8.1?
Comment #102
tkoleary CreditAttribution: tkoleary at Acquia commented@mgifford
Given other priorities, perhaps. Although given the fact that it is unquestionably an a11y improvement, maybe not.
Comment #103
mgifford@tkoleary I don't see the accessibility improvement. At least not when looking at the examples here:
https://select2.github.io/examples.html
It is a simple tool, but there are a lot of basic problems listed here:
http://wave.webaim.org/report#/https://select2.github.io/examples.html
I don't know how many are just part of the example code though.
I haven't had time to really look at it though. I do know that jQuery UI's autocomplete has had quite a lot of accessibility testing.
Can you point me to a comparison of the two for accessibility? Or even the documentation on the a11y work that's gone into Select2?
Comment #104
tkoleary CreditAttribution: tkoleary at Acquia commentedLast info I looked at was this issue https://github.com/select2/select2/issues/2499 that both you and I commented on which is now closed fixed. Since that time new a11y issues have been opened in 4.0, but (based on my own unscientific testing) 2499 puts Select2 well ahead of jquery autocomplete.
Here are the open a11y issues in select2 4.0
https://github.com/select2/select2/pull/2875 this one was opened after 2499 and was merged in on 12/09/2014
https://github.com/select2/select2/issues/3238 closed fixed
https://github.com/select2/select2/issues/3144 this one is still open as an enhancement but no longer marked a bug
I could not find other issues. We have an individual working with us here in Boston who may be able to test 4.0.
Comment #105
mgiffordI definitely think there has been progress with Select2 on accessibility, but I haven't had time to test it and it isn't clear to me that others have either. One of the last comments in #2499 is "Unfortunately I have no idea how to thoroughly test it as I only have limited knowledge of how Orca works, but perhaps someone else can help with testing."
That doesn't give me a lot of confidence.
I don't know how testing has been done or by whom. Select2 seems to have quite a few powerful options. I don't know if any of those have been tested.
There's some good addition of ARIA, but I still don't see how it's significantly better than jQuery UI for accessibility.
Comment #106
tkoleary CreditAttribution: tkoleary at Acquia commentedSome initial testing by Tyler Littlefield here in OCTO shows that in fact there is still a good bit of work to do. I plan on creating some new issues in the Select 2 queue on github.
Comment #107
mgiffordThe WP folks did a nice review of Select2 because they were considering it for WP Core - https://make.wordpress.org/accessibility/2015/09/07/accessibility-userte...
It would be great if we could work with them a bit more on addressing these issues.
Comment #108
subhojit777Comment #109
mgiffordAlso worth noting https://github.com/select2/select2/issues/3744
Comment #110
Gaelan CreditAttribution: Gaelan as a volunteer commentedRerolling.
Comment #111
catchComment #113
Wim LeersApparently there's a competitor to select2 that pays homage to select2, but tries to be better/simpler: https://github.com/arendjr/selectivity
Comment #114
mstrelan CreditAttribution: mstrelan commentedSelectize.js also claims to be have a few advantages to Chosen, Select2 and Tags Input. and http://selectize.github.io/selectize.js/ and could be worth considering.
Comment #115
tkoleary CreditAttribution: tkoleary at Acquia commented@wim leers
It does look simpler. Also bad on A11y but Select2 has not made much progress either, same for selectize. Just tested all three with screen reader.
Comment #117
vprocessor CreditAttribution: vprocessor at Skilld commentedattempt to reroll
Comment #119
tkoleary CreditAttribution: tkoleary at Acquia commented@vprocessor
Looks awesome! Despite failing tests it seems to work fine when I spin it up on simplytest.me.
One thing I noticed, the descriptive text would need to change (or just go away) in several places eg.
But that's a good problem to have.
Comment #120
joginderpc CreditAttribution: joginderpc at Material commentedUpdated all files with newer version of D8. Let's see if test passes.
Comment #123
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedRerolled, was just a simple conflict on core/misc/autocomplete.js
Comment #125
Bojhan CreditAttribution: Bojhan as a volunteer commentedComment #126
phenaproximaIt looks like the re-roll was botched at some point, and a missing file (or several!) was causing the test failures. Here's a new re-roll against 8.3.x, using Select2 4.0.3.
I apologize for the colossal patch size; the overwhelming majority of it is the Select2 library.
EDIT: Now that core has functional JavaScript testing, it seems like we might want a functional test of this widget against, say, a taxonomy term reference field. Do folks agree?
Comment #128
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedNote that #2788209: Entity reference field "Autocomplete matching: Starts with" option does not work added a (small) javascript test for the autocomplete widget, so we could expand it here if needed.
But IIRC, this issue was blocked on the fact that Select2 is not as accessible as we need for core, see comments from #103 to #107.
Comment #129
phenaproximaLooks like the WordPress people were interested in perhaps devoting some brainpower to fixing these issues; I can't tell if anything came of that, but maybe we could do the same? I really like this library and would quite like to see it in core.
Comment #130
tkoleary CreditAttribution: tkoleary at Acquia commentedGuessing this was copied from select 2 css and altered and that's where the indented rules come from. We should follow drupal CSS coding style here with no indents.
At first glance I thought it was Sass. :)
Comment #131
droplet CreditAttribution: droplet commentedAll good work here.
I think we need some final calls:
A1. [Frontend] Final analysis of the Performance. Select2 isn't a small kid thought.
If we can't pass A1. It's time focus on contributed and pick another one instead of dead loop :)
A2. [Accessibility] Final analysis of select2 itself (without Drupal)
A3. Basic usage. Testing in cross browsers (Checking the supports table in Select2 is not enough. In Drupal, we have very diff requirements.)
B. [JavaScript] Possible way to improve the Accessibility problem in Select2 Upstream & Drupal ourselves.
With my last patch to Select2 upstream ( https://www.drupal.org/node/2346973#comment-9255223 ), I think there's limitation to patch everything in Select2 upstream. Select2 also has itself design principal.
Comment #132
chr.fritschI could resolve some dependency issues. Looks like there is no Select2 object in version 4.
Comment #134
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot commented+1 This will be very very nice if we do have it in Drupal core and out of the box.
Comment #135
Bojhan CreditAttribution: Bojhan as a volunteer commentedI think this needs escalation to product, with a clear answer on 1.
Assigning to nod_ to provide some guidance.
Comment #137
pdenooijer CreditAttribution: pdenooijer at Ibuildings commentedI am looking forward to start using this feature, is there any update on the status of this issue?
Comment #138
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedMost conflicts are easy enough to fix, however core/misc/autocomplete.js has been changed by #2823589: Improve IME handling on Autocomplete so I'm stepping away from this reroll in fear of messing things up :)
Comment #139
droplet CreditAttribution: droplet commentedAnother choice:
https://semantic-ui.com/modules/dropdown.html
Comment #140
jonathanshawI suspect a lot of conflicts are not showing up because the patch hasn't been updated to allow for the fact that a lot of Entity Reference code has moved out of that module.
More generally:
Everyone wants this. But it's not showing any signs of going anywhere.
There's 4 tough hurdles to climb:
What chance of us achieving all this in one 15k-lines patch in 8.x?
How about we split this into 3 steps:
Comment #141
geek-merlin#140:
> How about we split this into 3 steps: ... (4 steps)
YES sounds very reasonable.
Comment #142
pk188 CreditAttribution: pk188 at OpenSense Labs commentedRe rolled. Not find all the changes. Not able to form interdiff.
Comment #144
jfs.csantos CreditAttribution: jfs.csantos at Bynder commentedI've just come across this while looking for a D8 version of the Select2 module.
I'm working on and already created a basic version of the module which creates a Select2 widget and a FAPI element ( which is what I needed initially.)
Anyone else working on this? Can we combine efforts and get at least a dev release ready asap?
Comment #145
jonathanshawSee https://github.com/ueberbit/drupal-select2
Comment #147
mgiffordHas anyone checked out selectwoo?
https://github.com/woocommerce/selectwoo
There's also someone from waggl.com willing to fund some accessibility work on select2:
https://github.com/select2/select2/issues/3744#issuecomment-314813909
Comment #148
droplet CreditAttribution: droplet commented@mgifford,
Good news! that is a @automattic supported project. and other supports from waggl.com
I have same concern as @claudiulodro in #131. I believe we need a smiliar fork or custom extension as woocommerce/selectwoo in druapl also.
1. and recently, when I worked on a custom project, I found the responsive doesn't work very well in select2 in many cases. e.g. rendered as a close Modal markup, Tabs. When it's shown, `width` didn't set correctly. ( https://github.com/select2/select2/issues/3278 )
2. down arrow on focus doesn't work. ( https://github.com/select2/select2/issues/4514 )
Comment #149
mgiffordThanks @droplet I do hope we can get this addressed in the 8.x cycle. Seems like there are a lot of folks who want a solution but there hasn't been someone yet to organize it. Maybe folks will rally behind selectwoo.
Thanks for posting those other accessibility bugs in select2.
Comment #150
droplet CreditAttribution: droplet commentedand there's a selectWoo issue:
https://github.com/woocommerce/woocommerce/issues/16003
Comment #151
jonathanshawjfc.csantos seems to have created https://github.com/Bynder/d8-select2
Comment #152
jfs.csantos CreditAttribution: jfs.csantos at Bynder commentedHi all!
I asked to contribute my version to the official select2 project but the maintainer didn't wan't to do it, so I'll just go ahead and create this one...it's holding my company back on releasing a few necessary features.
As soon as we can get my changes to the select2 project I'm more than happy to remove this one.
Cheers
Comment #153
droplet CreditAttribution: droplet commented@jfs.csantos,
AFAIK, after some point of 2016 Mid ~ 2017, you able to create "Yet another Select 2" in d.org freely.
With current movement, I think it's a bit hard to get Select2 into CORE.
Comment #154
Anybody@jfs.csantos (https://github.com/Bynder/d8-select2) & @webflo (https://github.com/ueberbit/drupal-select2)
I think it would make a lot of sense to release one of your module on drupal.org as project to
- make it easier to find it
- provide it via drupal.org composer
- combine into one project and use benefits from both, because drupal-select2 supports views filters for example while d8-select2 supports remote data?
The best would be to release it as D8 version of one of these projects:
https://www.drupal.org/project/select2
or
https://www.drupal.org/project/select2widget
or
http://hemantnegi.github.io/jquery.sumoselect/sumoselect_demo.html
or
https://www.drupal.org/project/selectize
instead of creating a further one??
At the end a Drupal core integration and replacement of the current solution would be perfect, but I think that will take some time...
Comment #155
jfs.csantos CreditAttribution: jfs.csantos at Bynder commentedHi there @Anybody! Thanks for the input, but I already tried to move in that direction...asked the maintainer of Select2 to upload an initial version of the D8 module, he said he didn't want to because in would be "releasing an official version in a few months".
Also considered releasing the module in Packagist or in drupal.org as a new project, but in the end they were temporary and not very good solutions.
So, in the end, because of my company's need for this to be released, we ended up just adding it as a submodule of the Bynder module. When/if we can actually get some cooperation from the Select2 project maintainer I will gladly contribute with this code.
If you guys still find the module useful, I can still put it up on Packagist.
Cheers
Comment #156
geek-merlin@all: This info and discussion belongs here: #2695535: [select2] Select 2
This is also the community place to discuss and decide the release policy.
Comment #157
AnybodyComment #158
nithinkolekar CreditAttribution: nithinkolekar commentedOffTopic: following this issue and got alert for new comment at dashboard as "1 new" but how come #154 changed it's comment time? Its not a big issue but would get messy afterwards.
attaching screenshot for ref..
Comment #159
alphawebgroup@Anybody
I'm really sorry... but I've just checked SumoSelect on github - https://github.com/HemantNegi/jquery.sumoselect
it contains pretty strange code inside (bad maintainability by my opinion), not sure if it will be acceptable by community
please check - https://github.com/HemantNegi/jquery.sumoselect/blob/master/jquery.sumos...
Comment #160
alphawebgroupbtw, why not Selectr?
https://github.com/Mobius1/Selectr
Comment #161
AnybodyThank you @alphawebgroup https://github.com/Mobius1/Selectr should also be considered. I also just had a look at sumoselect and share your oppinon. Did you have a a look at Selectrs code already?
The problem we see with Selectr is that it changes its height (1 line becomes multiline if many items are selected). This man be a problem for views filter layouts or on mobile devices and other cases. jquery.sumoselect offers the possibility to use "x selected".
See my quote here: https://www.drupal.org/project/contrib_tracker/issues/2695535#comment-12...
I created a feature request in Selectr for that but I don't think that will happen: https://github.com/Mobius1/Selectr/issues/56
Comment #162
thomas.frobieterI agree. This will make consistant (inline-)form styling nearly impossible. Those "Pill Style"-selects are just usefull for simple vertical forms.
Comment #163
matsbla CreditAttribution: matsbla commentedI needed this so contributed the module here if anyone else need it for D8: Select2 Boxes.
Comment #165
PanchoIf there’s still no viable, actively maintained jQuery widget, it seems we should really team up with WordPress and other consumers to maintain our own fork either of Select2/SelectWoo or another alternative.
I might be wrong, but I guess it’s not going to be more workload than putting more and more efforts into our own, outdated and limited autocomplete widget, especially taking into account all the effort site builders put into introducing their own custom implementations.
Either way it doesn’t seem realistic this would ever be implemented into Core within the D8 life cycle. May I push it to D9, while different routes are weighed in contrib? I’d love to see a major improvement, but fail to see it materializing... :/
Comment #166
jonathanshawI think this could easily be made available in core in D8, even if the default implementation didn't change.
Comment #168
jonathanshawIn #140 I proposed a 4 stage plan:
Now point 1 has been done, thanks to @chr.fritsch.
Therefore I've opened #2987622: Move Select2 to core as an experimental module in the ideas queue. I'm also suggesting we close this issue despite the heroic work here, because it's no longer Drupal practice to make large changes in core using single monolithic issues. If this going to happen, I imagine it will likely be via the experimental modules route.
Comment #169
andypostThis is not outdated, there are patches & valuable discussions.
I see no reason in experimental module while contrib has only first release & that is just a frontend library
Comment #171
AnybodyComment #172
AnybodyComment #173
AnybodyChoices.js is a new candidate which is now used by Webform: https://www.drupal.org/node/3046239
As the other libraries didn't match the requirements yet, this could be interesting.
Comment #174
thomas.frobieterThe markup of choices.js is pretty good, should be easy to alter the style for horizontal forms by removing the pill style and do something like:
Maybe the author of Choices.js is willing to add this as a clean option.
So +1
Comment #175
lauriiiBased on some quick research, this library seems like a pretty accessible option: https://github.com/alphagov/accessible-autocomplete. It's a React library, but we could use it as a comparison.
Comment #176
lauriiiComment #177
AnybodyComment #178
AnybodyComment #179
AnybodyComment #180
AnybodyThank you @lauriii for pointing out this very important reference. I've updated the issue summary to list some of the acceptance criteria and the mentioned libraries to evaluate. I'm unsure if we should remove the initial text from the issue summary, which only concerned select2 as option, but isn't really a good choice in several points. Or should we close this as duplicate and create a cleaned up issue based on this discussion?
Comment #181
bnjmnmI went ahead and prototyped how this might work with choicesjs to see what kind of unexpected surprises might show up.
The biggest of the surprises is that the best way to implement asynchronous autocomplete is to use choicesjs's 'search' event, and that event is only triggered on select elements. To get a feel for choicesjs, I added JS that converts all of the autocomplete
<input>
elements to<select>
. This got things far enough along to make it possible to evaluate the use of choicesjs on entity reference fields. However, since the form element is different, it's not currently possible to save values (or populate existing ones).I think this can be worked around if choices still seems like the best solution, whether they be in Drupal or the js library. This patch at makes it possible to evaluate how it may work in Drupal, which can help us gather evidence to determine if it's worth the implementation hurdles.
Comment #182
bnjmnmTwo patches here, the first is an improvement to the choicesjs prototype from #181, the assets are now added as part of drupal.autocomplete instead of jquery.ui.autocomplete.
The other patch is a prototype of using the Accessible Autocomplete library. This probably isn't a good candidate, unfortunately. Among other things, it does not support multiple values, and it only works with string arrays (no ability to have discrete values and labels).
I think the prototype is still very useful to have as reference when evaluating other libraries for accessibility support. There's also a good writeup on some of the research and testing that went into developing the library, which can help inform the evaluation process for this issue.
Comment #183
bnjmnmI had a look at Selectr, wondering if the concerns in #161 were surmountable. I didn't get too far in the evaluation after discovering that (similar to choices in #181), it requires a select element, and would not be able to work on existing autocomplete
<input>
elements.If its decided that changing the form elements is an acceptable refactoring, it may still be worth looking into Selectr and submitting a PR for the concerns in #161
Comment #184
bnjmnmCurrently working on a prototype for a custom lib based on React Select. Based on preliminary testing done with @lauriii, React Select does not have any of the major accessibility/functionality limitations we've run into with other libraries. So far, any issues we've run into are ones that can be addressed via implementation and not a limitation of the library itself.
Comment #185
Wim Leers#171: nice, your comment is exactly 1 year and 1 day since the last one 😆
Based on the prototyping work done by @bnjmnm this seems to be the current state:
<select>
, see #183@bnjmnm I think it'd be handy if you expand this initial table (I can give you the source HTML so you don't need to recreate it) and add it to the issue summary, that would make it very clear why which JS libraries are eliminated or still being considered.
My gut reaction here is that I am surprised we're not continuing to look at Select2 first, because as this issue's older comments show, we have successfully worked with the author of that library (a long time ago!) to get accessibility improvements committed. Accessibility is notoriously hard to achieve for user experiences like this, and having years of testing and feedback is a huge advantage.
Select2 still seems to be actively maintained: the last commit 11 hours ago, and it happens to be an accessibility improvement: https://github.com/select2/select2/commit/e5131d0cc8dffd98ba36a68f3d027b...! Look at the complexity of that commit message! 🤯
React-select had its last commit >1.5 month ago and it was just updating a dependency: https://github.com/JedWatson/react-select/commit/c22a4b20aef2161ebaa3a03....
https://github.com/JedWatson/react-select has 1160 open issues and 1250 closed ones. https://github.com/select2/select2 has 40 open issues and 4230 closed ones. Notably, https://github.com/JedWatson/react-select/issues/1084 has been open for over three years. https://github.com/JedWatson/react-select/issues/3353 means not even the label for the form input is being read by screen readers.
That's a lot of signals indicating that Select2 is more mature, which is important for an accessibility-critical UI component.
Comment #186
bnjmnm@WimLeers very good point about Select2 and that's definitely next on the list. The thought was to start with standalone libraries, or at the very least see what can be done without jQuery. Full (not at all surprising) disclosure: react-select definitely does not achieve the "standalone" part of that approach at all, and has the hearty node_modules directly to prove it 🙂
Also worth noting: One of the steps required to get the react-select prototype working made it apparent that Choices and Selectr may still be viable options even though they require a
<select>
element - the library doesn't have to directly manipulate the entity reference text input - the input can be made hidden and updated via the library-provided select input (similar to how Media Library keeps track of selections)Comment #187
chr.fritschFor select2 we have a stable D8 module in contrib. See https://drupal.org/project/select2. Currently, around 2000 sites are using it.
There were also some discussions around this in #2987622: Move Select2 to core as an experimental module
Comment #188
bnjmnmHere are patches for three prototypes
<select>
only limitation, the same approach was used for Select2) (also want to point out the lib isn't minified in this prototype)minified and it's still pretty huge.
Will follow up with another comment with some of my findings for each one, but as that may not happen immediately I wanted to make the prototype patches available to others so they can evaluate.
In each case, i just worked with taxonomy fields in the Article content type, so that's going to be the best place to evaluate these patches.
Comment #189
bnjmnmFindings for Choices JS
(some of the evaluation criteria is not included/complete as the review stopped after identifying numerous difficult-to-address accessibility problems - this can always be revisited if our other options have a similar extent of accessibility issues)
<select>
elements, does not work on text inputs (which means we can't work directly with the inputs provided by the Form API.)Classnames, deepmerge, fuse.js, redux
<select>
elements. The prototype demonstrates that things can be made to work by hiding the text input and syncing it with the values of the<select>
. One known issue with this is mentioned below, but there may be other unexpected problems too. Something important to note: this is one of the few libraries that can function at all with text inputs most features work fine with text inputs, it's just updating options via AJAX that doesn't. If it turns out that working on text inputs is critical, this library may require the least amount of customization in order to do that.<input>
elementsWill also add these findings to the issue summary after allowing a bit of time for feedback/corrections.
Comment #190
catchI think we should at least consider switching to a
select
element if that improves everything else. At the very worst this could be added as new elements/widgets deprecating the current one but even that might not be necessary depending on how we do it. i.e. if our options include both updating our existing widget and a complete visual update we should look at both. We might decide it's not desirable in the end, but doesn't seem worth ruling out up front. The big thing though is retaining AJAX autocomplete for scalability.Comment #191
Wim Leers#188: exciting to have 3 prototypes!
#189: Wow, love the deep analysis! Clearly you have a lot of accessibility knowledge 🤩👏 It sounds like some of those would be pretty easy to fix upstream, but others seem to perhaps be deeply embedded in the architecture.
Looking forward to an analysis similar to that of Choices in #189, but then for Select2.
#190: I was gonna say "but wouldn't that be too disruptive?" — then I realized that it's not
#type => textfield
with#autocomplete_route_name => …
, but we're talking about#type => entity_autocomplete
. So it seems we're fine there. Except … aren't we trying to remove the jQuery UI autocomplete altogether, which would require this to work for both cases?Comment #192
aspilicious CreditAttribution: aspilicious commented"The big thing though is retaining AJAX autocomplete for scalability."
This is very important for a lot of projects.
I know that select2 implementations of a normal select can go wrong with +1000 elements.
Comment #193
bnjmnmFindings for Select2/SelectWoo
Selectwoo describes itself as "a fork of select2 with improved accessibility", which was started when Select2 didn't have much activity on github. Select2 activity has since resumed, so any accessibility issues I identified on one I tried with the other. Assume the problems happen on both unless stated otherwise.
Similar to the ChoicesJS review, theres probably more to learn but I stopped after once the accessibility problem list had several potential dealbreakers. Note that the maintainers of Select2 seem quite open to addressing accessibility issues so it shouldn't be ruled out based on these findings alone several accessibility issues have been addressed within the past few weeks and several more are in progress.
<select>
elements. The prototype demonstrates that things can be made to work by hiding the text input and syncing it with the values of the<select>
. There are likely hidden downsides -- but the next point identifies one that was discovered<input>
elementsWill also add these findings to the issue summary after allowing a bit of time for feedback/corrections.
Attached patch is an updated prototype that works with items that have spaces and/or commas.
Comment #194
bnjmnmFindings for Chosen
This one did not get the Drupal prototype treatment, based on reviewing the repo and online demos I feel pretty comfortable ruling this one out
Comment #195
bnjmnmFindings for Selectr
This one did not get a Drupal prototype treatment, I reviewed the repo and online demos. If it's still in the running after these initial findings we can dig further.
Return key will not open selects - must be done with spacebar. This was reported early 2019 and another issue shortly thereafter.Looks like spacebar is less common but acceptable<select>
Comment #196
catch#91
We are trying to remove it altogether, but we could for example do #type => select with #autocomplete_route_name and deprecate #type => textfield with #autocomplete_route_name (but have #type => entity_autocomplete just update to the new system). Maybe?
Comment #197
geek-merlinKudos for the thorough analysis!
Let me add another criterion that was relevant in some projects:
* Can choices optionally be ordered? (In field storage we have this, often we don't want it and are happy that the widget ignores it, but sometimes we do!)
* Can we optionally have duplicate choices? (Same as above, sometimes we do need it)
It would be gold standard if we can settle on a widget that has (or can be extended to have) both options.
Maybe my research on this helps. (For the there favored selectize also see @kevinquillen*s Selectize.js)
Comment #198
Wim LeersWhat are the next steps here?
#type => select
and#type => textfield
with autocompletion in contrib modules. A quick search already surfaces several: http://grep.xnddx.ru/search?text=%23autocomplete_route_name&filename=Comment #199
bnjmnmMore!
Findings for Selectize
No prototype as I was able to gather enough information from online demos to provide an initial review. Something I'd like to highlight is that this is the first (multiselect-supporting) library I've tested that provides proper labeling for screenreaders . If we wind up preferring a different library that has this common input labelling problem, this library may help us identify the best way to fix it (unlike most of the libraries I've reviewed, the input is not hidden. It's placed inside the looks-like-an-input div that pretty much all these libraries use)
Comment #200
bnjmnmFindings for React-select
Demo
Prototype patch *(only tested with taxonomy autocomplete fields) *(terms with commas will not work properly, but that is easy to fix - this was just written before realizing that needed addressing )
Comment #201
bnjmnmFindings for Sumoselect
Going to rule this one out without a full table as it can be done pretty quickly:
Comment #202
bnjmnmAt this point, all the options listed in the issue summary have been evaluated. Accessibility looks to be a significant problem with each. The issues discovered came from just manual testing, so it's likely that more would be discovered as testing got more granular and rigorously checked against w3 specs.
These are some of the possible next steps that come to mind:
And there are likely other ways to approach this issue that I'm overlooking due to cognition-compromising effects of disappointing a11y testing.
Comment #203
webchickAMAZING work! :O :O
I think the next logical step here might be to overhaul the issue summary with a clear summary of results, and then try and get a wider audience (JS, a11y folks) to look at our findings and provide feedback. (Happy to tweet something out.)
Comment #204
Wim Leers#200: lol, >1 M downloads per week. It's painfully obvious that we're once again letting us be misled by something that is easily measured but the meaning of which is unclear. >1 M downloads/week does not mean >50 M sites/year are adopting this. It means people using that particular library tend to make many tiny commits that each trigger a test run that triggers a package download. Anyway … I digress.
#200:
😂😭
+1 to what @webchick recommended as next steps. I think that the two strongest contenders are
react-select
andselect2
. Is that correct?Comment #205
bnjmnmRe #204
Partially to save face 😊, but also important to clarify since I didn't effectively communicate it in the initial assessment - the conclusion that react-select is among the more popular options did take into account that React libraries get re-installed constantly. It's definitely not accurate to do a 1:1 comparison of NPM download counts. Most of the libraries evaluated had such comparatively low stats that I felt pretty comfortable classifying react-select as more popular. The library I couldn't conclude this with is Select2. It's likely the most popular based on ~200K weekly installs, many for sites that likely do not use the NPM-buffet approach.
And the the highest states happen to belong to what seem to be the best candidates: select2 and react-select .
Updated issue summary is on the way...
Comment #206
Wim Leers#205: I'm very very sorry 😞I should've been more clear. That small rant about ">1M/week" was not criticism towards you! Obviously you can compare npm download numbers across different npm projects. I'm just saying it is a silly metric to track in general. Just like it's ridiculous to pretend having 10K Drupal modules is a good thing (which we tend to do 🙃).
Comment #207
Anybody#199 Selectize sounded equally good to me based on your findings? Or did I get you wrong?
But let's wait for the comparison... I was just wondering about that sentence, following the mails from this issue.
Comment #208
droplet CreditAttribution: droplet commentedhttps://www.drupal.org/project/drupal/issues/1329742
data consistency would be a priority problem it should be reviewed. Also, a lib returned ARRAY better than CSV-alike STRING.
ARRAY > ALWAYS COMMAS ONLY > CSV-alike (Drupal)
Comment #209
jonathanshawI'm reminded of what was learnt recently on #2113931: File Field design update: Upload field. where hundreds of hours of work had to be discarded:
it's very very hard to retrofit accessibility to a complex component that was not designed for it from the ground up.
What I've not yet seen much discussion of is what Drupal core gate accessibility would look like for an autocomplete? We badly need a spec of some kind. Then we could assess how hard it would be to make any particular library acheive that spec.
The problem is that it is not possible to make an inference from A to B to C where
A) this library has made some/much apparent effort to deliver accessibility by using lots of aria syntax etc
B) this library has even 95% of the accessibility we need
C) it will be easy to bring it up to 100%
As I understand it core gates for accessibility are not very flexible by nature: close to compliant is still not acceptable.
What @bnjmnm has brilliantly demonstrated is that are significant concerns with every library and no standout winner.
What spec to use? A knowledgeable user in this comment:
https://github.com/select2/select2/pull/5571#issuecomment-514923004
suggests:
Do our accessibility maintainers agree?
If we do, then I suggest the question we would need to answer is:
for any given library, what would be the hardest aspect of getting it to match that spec?
It's the hardest aspect that is ultimately the critical one when success is a binary pass/fail as it is here.
I appreciate that this is a hard question; but the experience of #2113931: File Field design update: Upload field. suggests it's risky to work on developing accessible components by starting with low hanging fruit.
Comment #210
bnjmnm@jonathanshaw from #209: +1 on defining the a11y spec this should adhere to so we can factor that into the evaluation process. I've updated the issue summary and included that in the remaining tasks.
Comment #211
bnjmnmComment #212
bnjmnmComment #213
webchickThanks for the issue summary updates! Ok, posted this to Twitter to hopefully get it in front of a wider set of eyes. https://twitter.com/webchick/status/1159727661897273344
Comment #214
webchickOne that was brought up in that thread that doesn't seem to be here yet is http://leaverou.github.io/awesomplete/ (apparently one of the ones under consideration for Joomla! 4, according to https://twitter.com/brianteeman/status/1159733875377135622)
Comment #215
webchickAlso cross-posted to the #accessibility channel in Slack.
@andrewmacpherson there noted (verbatim apart from fixing a few typos for clarity):
Comment #216
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commented@bnjmnm - thanks for the big survey!
Comment #217
droplet CreditAttribution: droplet commentedI appreciate the hard-working on the WCAG reviews but there are many basic problems we have to address them.
(It helps us to save our time for difficult WCAG reviews.)
#214
Generally, unstyled tagging lib can kick it out.
For unstyled tagging, we need to provide a way to edit the middle tag. For example, we expected to change "JavaScript" below will popup another new list to select. (This is a Code bug, UX problem, also WCAG I think)
"CSS, JavaScript, HTML"
Comment #218
droplet CreditAttribution: droplet commentedIf we think out of the box, we can change the tagging and multiple selection design. So call it Drupal Pattern.
For instance, we can use the WordPress way to add a tag. Then, we only need a lightweight SINGLE-selection lib (dropdown + filter)
Comment #219
webchickAnother library raised in the Twitter thread that's not here yet. https://github.com/github/auto-complete-element (via https://twitter.com/dgrammatiko/status/1159820163547566081)
Comment #220
mgiffordMy comments are more about the replacement for jQuery UI autocomplete. The better multiselect library is a bigger challenge, and I still haven't found anything that does it for me. It also hasn't been a priority lately.
The GDS in the UK did this piece last year talking about their solution. They also published these examples.
Dennis Lembree (@webaxe on Twitter) pointed me to the GDS blog post as well as one of his own autocomplete demos.
I don't know if the downshift WAI-ARIA compliant enhanced input React components are an option at this stage. Here's the downshift example page. I was pointed to this on Twitter by @devisscher.
If what we ant to do though is replace it with something like Select2, not sure there is an accessible one that has come up and is well supported since this issue was created almost 5 years ago. I wonder what solutions communities like WordPress & GatsbyJS are using.
Comment #221
bnjmnmI did a quick accessibility review of the Wordpress tags field and it's one of the better ones so far. :The issues I found are all things that could be addressed without much difficulty (were I to evaluate more strictly against W3 specs, it's possible I'd discover trickier issues).
The Javascript that does this is React-based and seemslike it is very threaded into Wordpress' overall architecture. Does not look like something that could be easily ported to another CMS. but I think these findings are still valuable.
having multiple values in a single text input, but really bad for screenreaders since there's nothing to indicate the field has any values until it's been navigated past.
Should also point out the Wordpress approach - like most of the options reviewed - has the same concerns first mentioned in #161, where the field height may increase with multiple values. The only way for this to not happen (without horizontal scroll on overflow) is to use a text field.
Comment #222
bnjmnmhttps://github.com/github/auto-complete-element findings
This is a pretty quick one to rule out so not bothering with the table-treatment unless made aware of an obvious benefit.
Comment #223
bnjmnmAwesomplete findings
https://leaverou.github.io/awesomplete/
The attached prototype was tested with taxonomy autocomplete on the article content type.
Expanding on something mentioned in #214 it looks like this was added to Joomla ~summer 2018 (possibly earlier). I hoped to find a lengthy issue like this one where Joomla vetted the heck out of it , but the closest I could find was https://github.com/joomla/joomla-cms/pull/20888 -- which at the very least seemed like success with using the library.
The NPM stats are on the lower end compared to other libraries, but its use in Joomla probably evens that out a bit -- it seems like its used widely enough that there's been many pre-existing users around to identify major problems so Drupal users don't have to
The biggest issue I found only happened with the online demo, where sometimes an option would be highlighted that was not focused/active. Did not encounter this issue when used in Drupal.
Comment #224
Ghost of Drupal PastLet me add awesomplete to the IS. This is , well, awesom(pl)e ;)
Comment #225
bnjmnmUpdated issue summary to bring in the policy people. Also tagging with "needs followup" to create an issue that represents the original intent of this issue when it was created in 2014 - to improve the UX of select elements.
Comment #226
BerdirWhat about terms with commas in them? That's very confusing to deal with in our current autocomplete. At least the demo doesn't seem to support that, with those simple data lists, but I guess the custom matching that I saw in one example should allow to reimplement the existing hacks we have with quotes and stuff?
Another use case is identical labels, our workaround there is the "Label (ID)", which I think is another thing that's pretty confusing to inexperienced users, especially for the private message module, where a lot of regular users came into contact with that and I got lots of issues about that.
In other words, looks like the focus of this issue shifted to basically doing a drop-in replacement of jquery UI autocomplete with a library that does the same thing, with the same advantages and disavantages? I guess that does make sense considering that we need to get rid of the jQuery UI components and it seems to be pretty much impossible to have UI improvements without a11y drawbacks?
Maybe that would better be done as a separate, new issue though, rather than changing the goal of this one at 200+ comments? :)
Comment #228
Wim LeersIt's impressive that the solution that is being proposed after extensive research is one consisting of only 552 lines of code. The difference in size with several others is
strikingmind-boggling. 2KB versus at least 68 KB forselect2
(and at most 77 KB) versus 250 KB forreact-select
.Given that you've done such a deep analysis, I'm wondering if @bnjmnm could share his perspective on why there is this a multiple-order-of-magnitude difference. The two obvious questions: A) Do the others do so much more? B) Are they needlessly complex? I'm sure the answer is somewhere in the middle.
Comment #229
amateescu CreditAttribution: amateescu for Pfizer, Inc. commented@Berdir:
I was also interested in this and, by looking the documentation, it seems that Awesomeplete will be able to fix this long-standing problem for us:
Comment #230
bnjmnm#226
The implementation of the prototype patch includes being able to add/create terms with commas and/or spaces the same way it currently works in core.
#228
The difference is substantial enough that it's probably worth reviewing the code of some of the other candidates to see if they address use cases that Awesomplete does not.
Comment #231
joegl CreditAttribution: joegl commentedIs this actually a problem with the current JQuery UI Autocomplete or it's core implementation? As far as I know, drupal core inserts the label into the input instead of the value, and this wasn't a constraint or design decision forced by JQuery UI Autocomplete. I'm not in anyway stating we shouldn't move on from JQuery UI Autocomplete, but just wanted an answer on this. The reason for this I believe is the need to store the value while still showing the label to the user (by appending the ID's with the labels in parentheses to regex them out later). It appears Awesomplete does solve this, but I'm not entirely clear on how.
EDIT: Apologize for all the edits and if this is redundant, I'm just excited about this!
Comment #232
Wim Leers#230: Thanks, that's a very helpful overview!
http://leaverou.github.io/awesomplete/, search for "AJAX" — AFAICT it's intentional that awesomeplete does not itself do the AJAX request :)
So this gets to the very essence of my original question: the other libraries have more features, but do we need them? It sounds like the answer is "no"?
Comment #233
Berdir@Wim: See #226. Depends on your definition of "need". We don't need them to replace jQuery UI Autcomplete as it's very similar to jQuery UI Autcomplete in how it works based on what I understand *but* the original purpose of this issue was to have something *better* than the current UI.
And in regards to the key/value stuff in #229, I don't think that actually helps because in the end, it's still a simple textfield that's submitted to the server and needs to be parsed. As discussed in Slack.
Unlike select2 and similar libraries, where a selection is a thing that has an internal, non-visible ID and a label, just like a select option that we can submit and reliably process. But all those implementations have all these a11y problems.
So as I said in #226, I think it would make sense to create a new issue for our new goal (which now is to get rid of jQuery UI asap, not improve what we have), and keep all the investigation/research here open.
Comment #234
catchJust catching up on this, but from an issue management perspective I agree with #233. It sounds like we can do a near-drop-in replacement of jQuery UI with awesomplete, and we should open a new issue for implementing that.
Then this issue can stay open for its original purpose with all the new research, which has been really useful in its own right and can continue independently of replacing jQuery UI.
Comment #235
lauriii+1 to #233 and #234. Let's open another issue to discuss replacing jQuery UI autocomplete with awesomplete and keep this open to continue discussion around libraries that could be used to achieve the UX improvements.
Comment #236
bnjmnmNew issue has been created for the jQueryUI autocomplete replacement #3076171: Provide a new library to replace jQuery UI autocomplete, and the issue summary here has been brought back to it's original intent.
Comment #238
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedThere's something in the evaluation approach which should be avoided in future...
#200 says:
I was puzzled by what this meant. Elsewhere I see grepping for mentions of "aria" was part of the evaluation. But what does healthy mean here - a lot of matches, or few matches?
Never give any weight to this count. It's highly misleading because:
I appreciate the level of detail in the evaluation comments - so much to digest. The ARIA grep count shouldn't be given any credence though.
Comment #241
catchMarked #2520416: Autocomplete node ID numbers are confusing, only display when required as duplicate.
Comment #243
andypostit's 9.4/10.0 now
Comment #244
Anybody@bnjmnm: With a lot of awesome work in #3076171: Provide a new library to replace jQuery UI autocomplete done, is A11y_autocomplete (npm package from that issue) also a candidate to solve the other UI / UX improvement requirements mentioned in this thread?
Like X-Device (multi)-selection with filtering for large lists, ...
If yes: What's the strategy?
Extending the library itself? Adding a dependent package?
If no: How can we proceed here and how can decide that?
In the meantime, the analyzed libraries also received relevant updates (e.g. https://github.com/select2/select2/pull/5571) so that the best candidates from above:
should be re-evaluated. Together with that re-evaluation I think it would make sense to add a table to the IS which shows in one sentence if a library is still an option at all with links to the details, like for
?
Comment #245
bnjmnm@Anybody Glad there's still interest in this!
While
A11y_Autocomplete
certainly isn't capable of this out of the box, it should be able to support this kind of customization. It definitely did when I initially built it, I assume it still does after recent changes (but I can't say 100% since I haven't evaluated it since those changes).I believe most of it could be accomplished by adding event listeners that only fire if the autocomplete input has an attribute indicating it should be multiselect. It may also require instance method or two being overridden, but this should be possible
I'm not sure how long it will take for
A11y_Autocomplete
to get into core - there are many moving parts to consider. AnA11y_Autocomplete
solution could be provided as contrib, though. A great contrib solution may be the most convincing way to get it into core.As for the other solutions:
All of those options include the approach of the selected items being inside the input. The multiselects I've seen that provide better accessibility (in my opinion at least) display the selected items outside of the input, and use the input only for adding new items. I'm unsure if there's a semantically correct way to have interactive "pill" items within an already-interactive input .
Comment #246
Anybody@bnjmnm: Thank you for your super quick and informative reply!
So if I get you right and based on that list, you'd vote for extending A11y_Autocomplete to provide the other relevant options. I agree that this makes sense and Drupal would benefit a lot to have such a complete, out-of-the-box solution.
Using a A11y_Autocomplete module until it's in core is also a good idea once A11y_Autocomplete library has these options.
I found this one: https://www.drupal.org/project/a11y_autocomplete is that what you mean?
As the other relevant libraries don't seem to be a good option anymore and this issue is very long, would it then perhaps make sense to create an issue based on / referencing this issue and #3076171: Provide a new library to replace jQuery UI autocomplete to define and discuss the additional features needed additionally to the jQuery UI autocomplete replacement?
We could compare the relevant features from the listed libraries and based on your great analysis in this issue and create a list of required features. For example the select-list, filtering, etc.
Alternatively, we could do it outside of Core's issues here: https://www.drupal.org/project/issues/a11y_autocomplete
or is there any GitHub Repo I didn't find yet?
Or would you like to proceed in this issue?
It would be nice if you could lead the way, as you're deeply involved!
Comment #249
smustgrave CreditAttribution: smustgrave commentedOne module that's helped our projects is https://www.drupal.org/project/cshs which has a submodule for menus.
Comment #250
xjmComment #251
xjmClosed #191360: Scalable menu selector and #3110371: When adding a new menu link, restrict the available parents to the current menu as duplicates of this issue.
Comment #252
joseph.olstad@xjm, how does this close out #3110371: When adding a new menu link, restrict the available parents to the current menu ?
I'd like to test you on this performance issue. Is there some sort of ajax call being proposed to load children as needed? so select a parent and then the children are ajax loaded? Without patching, core currently loads an entire tree for ALL menus is loaded when we use a menu link in a node edit form. 3110371 fixes that by loading the expected menu rather than ALL menus.
#3110371: When adding a new menu link, restrict the available parents to the current menu
is not only a performance fix, it's a huge usability improvement. To elaborate on a fix for this would be to solve the edge case of situations were one might want to use the node edit page to move menu links around however I argu that the menu system admin ui should do that, not the node edit form.
Have you ever used menu links with the node edit form?
Comment #253
joseph.olstadthis patch
#3110371-27: When adding a new menu link, restrict the available parents to the current menu
This patch is Passing 100% success, this proves that the edge case that the patch removes and mentioned by @catch wasn't important enough to write an automated test for. If the edge case was important enough there would have been an edge case test and the patch would have caused a test failure.
IMHO, this patch provides a significant usability improvement and it also is a performance improvement from default core behavior.
Simply tossing a working solution aside without providing an improved equally or better solution we can use immediately is a bit disappointing. At least an explanation and some sort of rationale would be appreciated.
With all this said, I'd be curious to try perhaps another approach to perhaps instead of use menu links to see if taxonomy terms would work better. AFAIK when loading a taxonomy term UI core doesn't load all taxonomy terms trees for all vocabularies like the menu tree is doing so it might be a better approach to rely more on taxonomy.
https://www.drupal.org/project/taxonomy_breadcrumb
instead of
https://www.drupal.org/project/menu_breadcrumb
With that said, the default core behavior of menu links has always since Drupal 6 been a pet peeve of mine, it's a rats nest to navigate assigning a menu link to a parent without the patch.
As for the edge case brought up by @catch, I suggest deleting the menu link from the wrong menu and manually creating a new one in the intended menu would match exactly how taxonomy works where terms are not saved to other vocabularies without the convert_bundles contrib module being involved.
IMHO, core behavior of menus should be patched as proposed several years ago in #3110371: When adding a new menu link, restrict the available parents to the current menu
Comment #254
xjm@joseph.olstad, you're welcome to explore alternatives in contrib. The fact is, though, that core has many non-performant long select fields that can whitescreen or even take down sites, fields that need to be replaced with reference or hierarchical widgets. Adding HTML number widgets to core fixed some of them, but not the ones that have hierarchy. It's the same problem in multiple places, so we should fix it at the Field API level. This is the issue with the most recent holistic approach to that, so I'm folding menu selection into the scope. Thanks!
Comment #255
joseph.olstad@xjm,
yes contrib, I'm curious if there's an inventory of options for contrib here?
So for menu links I've created sansdesordre (without a mess), a very simple module.
It doesn't have the performance benefits of the mentioned core patch.
Related usability improvements offered by contrib
modules that improve the UX but not necessarily deal with scalability from a performance perspective:
libraries mentioned by @Anybody
#2346973-246: Improve usability, accessibility, and scalability of long select lists
Related core issue:
#3076171: Provide a new library to replace jQuery UI autocomplete
What about core performance/scalability?
If you have anymore insight into the related core roadmap and high level decisions on the direction for this please share.
If there's other possible contrib solutions or perhaps a way to enable a performance improvement to enable a UX/performance/scalability solution in contrib then please share plans/ideas/references or discuss.
Thanks
Comment #256
xjm@joseph.olstad, whatever solution we pick has to pass the performance gate, so scalability will definitely be taken into account. And anything that doesn't load an entire giant database table into a single field on page load is going to be an improvement, or at least, it'd be difficult to make it worse.
Comment #257
andypostOne more related #3265408: Provide an element that converts large radio/checkbox option to select list
Comment #259
mgiffordThis is definitely a long issue. Thanks for all the work everyone.
On accessibility, always good to look upstream to awesomplete https://github.com/LeaVerou/awesomplete/issues?q=is%3Aissue+is%3Aopen+ac...
Also, I'm encouraged it is code by Lea Verou.
Comment #260
Chi CreditAttribution: Chi commented[Deleted] (wrong issue)
Comment #261
donquixote CreditAttribution: donquixote at European Commission and European Union Institutions, Agencies and Bodies commentedA strategy could be like this:
Part of this can be an entity iterator, another part can be caching of entity labels, and caching of complete option lists. #2846426: Options Select Widget: High Memory usage,
#2577417: Add an entity iterator to load entities in chunks, #1199866: Add an in-memory LRU cache.
This can be useful if we have something like < 500 options.
We could even load the list as a separate request, so it can be cached separately _and_ does not impact initial load time.
(Chosen or slim_select already do this for select lists, but not yet for autocomplete, afaik)
I see discussion around point 3 (client-side libraries) in this issue, but it is not really 100% focused on that.
Perhaps we should open individual issues for the different aspects?
Comment #262
donquixote CreditAttribution: donquixote at European Commission and European Union Institutions, Agencies and Bodies commentedhttps://www.drupal.org/project/autocomplete_deluxe
This module does it.
It acts like an equivalent to chosen or slim_select for autocomplete.