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

Survey task filter radio button labels use nested buttons #3919

Open
eatyourgreens opened this issue Nov 26, 2022 · 7 comments · May be fixed by #6574
Open

Survey task filter radio button labels use nested buttons #3919

eatyourgreens opened this issue Nov 26, 2022 · 7 comments · May be fixed by #6574
Assignees
Labels
accessibility Improving the experience for users of assistive technologies bug Something isn't working FEM spreadsheet Tracked in the FEM Planning spreadsheet (for zoo team members)

Comments

@eatyourgreens
Copy link
Contributor

Package

lib-classifier

Describe the bug

The label for each filter radio button includes a close button when the radio button is checked. <label> tags can only contain inline text and images. Nested <button> tags are invalid and raise an accessibility issue. With one clickable element nested inside another clickable element, the label's behaviour is not obvious when clicked.

{checked && (
<CloseButton
closeFn={(event) => {
// Note: preventDefault and stopPropagation are to prevent the radio button input click handler from firing and re-selecting the characteristic filter
event.preventDefault()
event.stopPropagation()
onFilter(characteristicId)
}}
/>
)}

The radio button's label is also confusing, since it contains the close button label.
Radio button label saying: antelope/deer Remove antelope/deer filter.

To Reproduce

Select a filter then inspect the radio button label in the DOM.

Expected behavior

Labels should use valid HTML and not generate accessibility errors.

@eatyourgreens eatyourgreens added bug Something isn't working accessibility Improving the experience for users of assistive technologies labels Nov 26, 2022
@mcbouslog
Copy link
Contributor

mcbouslog commented Dec 6, 2022

Maybe the close / remove button should be removed.

With the desired UI of selecting or deselecting one item, and only ever one item at a time, from a group of items, what's the best implementation?

Maybe a checkbox group with that only allows one item to be checked?
Maybe a radio button group with onClick that unchecks checked inputs?
Something else?

@eatyourgreens
Copy link
Contributor Author

Maybe a checkbox group with that only allows one item to be checked?

This is basically re-inventing radio buttons, albeit with the option to turn one off. Checkboxes have a completely different keyboard interaction from radio buttons, so the design would have to clarify, visually, that the interaction is different.

@eatyourgreens
Copy link
Contributor Author

We could also allow multiple selection. See, for example, the filtered search on https://www.johnlewis.com/search?search-term=coffee

@eatyourgreens
Copy link
Contributor Author

Radio buttons are a good choice when only one answer can be selected but always provide an extra option eg. Male/Female/Prefer not to answer.

@eatyourgreens
Copy link
Contributor Author

The GDS guidelines for radio buttons are worth reading.

@mcbouslog
Copy link
Contributor

Not suggesting we mirror, but for reference here's what PFE does. PFE provides a Clear button that's only enabled once a different option within the related characteristic group has been selected, and when Clear is clicked it clears and closes the related filter section.

Project with survey task - https://master.pfe-preview.zooniverse.org/projects/markb-panoptes/survey-task-test-project/classify?reload=0&workflow=2434&env=staging

The linked GDS guidelines note:
"Users cannot go back to having no option selected once they have selected one, without refreshing their browser window. Therefore, you should include ‘None of the above’ or ‘I do not know’ if they are valid options."

I'm not sure, but I think the two options to consider are:
a) changing the characteristic section to a checkbox group and allowing the selection of multiple specific values (i.e. red AND black)
b) keeping the characteristic section a radio group and adding a "no filter" option

@seanmiller26 - what are your thoughts?

@seanmiller26
Copy link
Contributor

seanmiller26 commented Dec 8, 2022

I have reconfigured the functionality to be checkboxes instead of radio buttons.

Screen Shot 2022-12-08 at 1 31 48 PM

This allows volunteers to make multiple selections. Notice a tally counts the active filters next to the 'Filter' button and a 'Clear All Filters' button only shows when a selection is made. There is also an overlay applied to the checkboxes to make the checks more visible.

Screen Shot 2022-12-08 at 1 33 28 PM

Here is how it looks after the selections are made and the filter dialog closes. Volunteers can see there are filters applied but would have to go back into the filter dialog and choose new selections, similar to PFE's current functionality.

Screen Shot 2022-12-08 at 1 33 37 PM

Let me know if there are other functionalities I have missed.

@mcbouslog mcbouslog removed this from the Survey Task: Pathfinder Projects milestone Jan 13, 2023
@goplayoutside3 goplayoutside3 added the FEM spreadsheet Tracked in the FEM Planning spreadsheet (for zoo team members) label Jan 14, 2025
@mcbouslog mcbouslog self-assigned this Jan 15, 2025
@mcbouslog mcbouslog linked a pull request Jan 16, 2025 that will close this issue
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Improving the experience for users of assistive technologies bug Something isn't working FEM spreadsheet Tracked in the FEM Planning spreadsheet (for zoo team members)
Projects
None yet
4 participants