ic-ui-kit icon indicating copy to clipboard operation
ic-ui-kit copied to clipboard

Make disabled options on ic-select focusable

Open GCHQ-Developer-847 opened this issue 1 year ago • 12 comments

Summary

Make disabled options on ic-select focussable so that focus behaviour is consistent with popover menu component and to help make it clearer to screen reader users that the option list includes disabled options.

💬 Description

Currently, if you focus through the options on an ic-select (with all three variants - single, searchable and multi) using the up and down arrow keys, the focus skips past any disabled options.

After discussing this issue during an accessibility testing session, and with a designer (@DBD324), we decided that it would likely be clearer for screen reader users if disabled options were focusable so it is more obvious that they exist.

This ticket is to make the disabled options focusable and apply the styling used on popover menus, where the disabled options display a dashed line as shown below when focussed:


Note: I assume we would want to apply this change to the multi-select as well so that it's consistent with the normal / existing ic-select variants - particularly as it would be quite a big / noticeable difference. This means that the change will need to be added to the multi-select code in the canary folders (canary-web-components and canary-react) as well as in the normal folders.

💰 User value

This would bring the behaviour of ic-selects with disabled options in line with the behaviour of those on popover menu components, and help make it easier for screen reader users to understand when some options are disabled.

📚 User Stories

As a screen reader user I need to be able to focus on disabled options on an ic-select So that I can easily tell that there are options present which are disabled.

📝 Acceptance Criteria

Given that I am using up and down arrow keys to focus through options on an ic-select When I come to a disabled option Then the disabled option becomes focussed rather than skipping onto the next enabled option.

Given that I am a screen reader user using an ic-select When I focus on a disabled option Then the screen reader tells me that that option is disabled.

✏ Designs

A focused disabled option on an ic-select should have the same appearance, measurements, spacing etc. of that of a popover menu component.

GCHQ-Developer-847 avatar Feb 19 '24 18:02 GCHQ-Developer-847

Need a clear answer if we are doing this, but also if this is needed for other components

MI6-255 avatar Apr 24 '24 08:04 MI6-255

When we implement, consider if it'll break tests (when doing the dev work, move to v3)

MI6-255 avatar Apr 24 '24 08:04 MI6-255

Match popover styling as close as possible

MI6-255 avatar May 02 '24 09:05 MI6-255

Give notice before making this change on the channel and in the release notes

MI6-255 avatar May 02 '24 09:05 MI6-255

Will this affect search bar? Although no disabled items in it

MI6-255 avatar May 02 '24 09:05 MI6-255

I think the solution may involve changes to loadUngroupedOptions(). This is where this.ungroupedOptions is set; this.options contains all options passed to the options prop so can include parent options (used to create groups) and disabled options, but this.ungroupedOptions only contains enabled options and child options, i.e. the options that are currently focusable (this is passed to setNextOptionValue() and setPreviousOptionValue(), for example, to determine which option to focus next when the user is using the keyboard).

So I think it might at first basically involve a change to what this.ungroupedOptions is set to.

GCHQ-Developer-847 avatar May 02 '24 09:05 GCHQ-Developer-847

Mention in the guidance site how this works

MI6-255 avatar Jun 26 '24 10:06 MI6-255

Spent some time investigating this and made some initial progress with the suggestions from @GCHQ-Developer-847 above, but it showed that the remaining work will be quite involved, so think it it worth refining again.

Due to the way ic-select and ic-menu interact, there would need to be quite a bit of refactoring\rewriting of the code to highlight an option. At the moment it relies closely on the value in the input field to determine when to highlight an option\mark as selected. However, if a disabled option cannot be selected, this cannot be used as way of determining when to highlight it.

Design input may also be required on what should happen in some scenarios. For example, what should happen when you press the ArrowDown key in this scenario:

image

Should the value Cappuccino remain in the input and also the Cappuccino menu item remain with a tick, but focus now be on Latte? If that is the case, are there any accessibility considerations around this behavior?

Also to be considered is that any changes will need to be duplicated\extended to work in the canary ic-select-with-multi code, to keep this in sync with ic-select.

ad9242 avatar Jul 01 '24 15:07 ad9242

this is currently on hold, until #2108 is complete. Otherwise this will be much more complex to complete\require lots of code duplication

ad9242 avatar Jul 04 '24 10:07 ad9242

moved back to design so figma can be updated with styling

ad9242 avatar Jul 04 '24 11:07 ad9242