Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add static select2 to choice widgets #2400

Closed

Conversation

thegcat
Copy link
Contributor

@thegcat thegcat commented Dec 31, 2021

This is a rough proof of concept (the code is mostly copied from pretixcontrol, the custom select2 css from pretixcontrol has not been copied, I have no idea how necessary it is for presale) to add select2 features to single choice questions. This can be refined by only enabling select2 when there are more than a threshold number of choices or by having a setting to enable this on a per-question level (I don't see the harm having this on all the time though).

This uses the in-place version of select2 to gracefully fall back to a normal select with all options available should the user use a non-js client or a screen reader or similar. Even if the question has lots of choices (we regularly have more than 100) it should be efficient enough without requiring the dynamic/server-query based version of select2.

Fixes #2020

@cla-bot
Copy link

cla-bot bot commented Dec 31, 2021

Hey there! :) Thank you very much for offering a contribution to pretix! For legal reasons, we need you to sign a Contributor License Agreement in order to be able to merge the code. Sorry for the hassle :( Please download the agreement from https://pretix.eu/about/en/cla and send a signed copy to support@pretix.eu. Feel free to also contact us there or via comments here if you have any questions!

@codecov
Copy link

codecov bot commented Dec 31, 2021

Codecov Report

Merging #2400 (82b4fa7) into master (451d3fc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2400   +/-   ##
=======================================
  Coverage   78.40%   78.40%           
=======================================
  Files         363      363           
  Lines       47311    47312    +1     
=======================================
+ Hits        37095    37096    +1     
  Misses      10216    10216           
Impacted Files Coverage Δ
src/pretix/base/forms/questions.py 74.65% <ø> (ø)
src/pretix/presale/context.py 78.43% <100.00%> (+0.21%) ⬆️

@raphaelm
Copy link
Member

This is in the critical checkout path, as noted in the issue this can only move forward if we clarify accessibility impact. @wiffbi is on vacation next week but maybe can try to find out more after that.

@raphaelm
Copy link
Member

After we've had specific feedback from blind users now that select2 is unusable for them, I'll close this. We can revisit when (and if) we have a select2 alternative that fulfills all of our other requirements.

@raphaelm raphaelm closed this Dec 20, 2022
@thegcat
Copy link
Contributor Author

thegcat commented Dec 20, 2022

This is surprising to me, as select2 as used only injects behaviour when js is active (i.e. should work with screenreaders) and at least on the select2 docs it seems to go out of its way to add aria tags to the generated markup, but well. Thanks for investigating this.

@wiffbi
Copy link
Contributor

wiffbi commented Dec 21, 2022

Screenreaders don’t disable JavaScript, they just use the browser API to access what is on the page. I read the docs on select2 and it seems to use all the right aria-attributes and roles, but in practice it still does not work. I don’t know why they go all the way to add these aria-attributes and roles, but it seems they do not test with a screenreader. I tested with VoiceOver with Safari on Mac and can confirm the reported findings from JAWS (Chrome, Firefox) on Windows, that select2 does not really work with a screenreader as the options are not read aloud. One can type into the search box and even use the cursor-keys, but nothing is read until confirmed with return/enter. So not really useful. What works with a screen-reader is the example on W3-ARIA examples, e.g. https://www.w3.org/WAI/ARIA/apg/example-index/combobox/combobox-autocomplete-list.html I will look into this whether that is something that can be fixed in select2 with a PR or if we should look into something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional search for dropdown/select questions
3 participants