fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

ComboBox accessibility: Tabbing/dismissing callout toggle selection

Open erichdev opened this issue 6 years ago • 6 comments

Environment Information

  • Package version(s): 7.129.0
  • Browser and OS versions: Chrome 84.0.4147.125, Windows 10

Describe the issue:

In ComboBox, with multiselect and freeform allowed, if you're focused on an option, pressing tab unexpectedly toggles the selection.

Please provide a reproduction of the issue in a codepen:

Repro: https://codepen.io/erichdev/pen/yLOaqbr

  1. Select a ComboBox option and close options callout (mouse at this point is fine)
  2. Focus on ComboBox input
  3. Press enter to open options
  4. Arrow down to selected option
  5. Press TAB to move focus
  6. The selected option is no longer selected.

Actual behavior:

When focused on a ComboBox option, pressing TAB will toggle the selection.

Expected behavior:

Tab should move focus to the next element without affecting selection. While focused on an option, pressing Enter correctly toggles selection; tab should not affect selection.

Documentation describing expected behavior

erichdev avatar Aug 19 '20 23:08 erichdev

A similar repro is:

  1. Open the ComboBox options callout.
  2. Keyboard arrow down to any option.
  3. Press enter to select the option.
  4. Click outside the ComboBox to dismiss the callout.
  5. The option is no longer selected.

Seems the values are being updated on dissmiss/on blur.

erichdev avatar Aug 19 '20 23:08 erichdev

@erichdev Thanks for the great repo steps in your codepen!

@khmakoto - I believe the main issue is that the user expectation here is that if you arrow key to an option in the ComboBox and press Tab it should behave as if you pressed Esc, but it actually selects the option... which feels strange as Enter is the primary keyboard selection method.

paulgildea avatar Aug 20 '20 15:08 paulgildea

@paulgildea This appears to be expected behavior. There are explicit checks to automatically select an option if focus is lost, even if it's a multiselect. @jspurlin do you have any insight as to the expected behavior? We can remove that blur autoselect, which I think makes the most sense, but that could be seen as a breaking change depending.

joschect avatar Aug 29 '20 02:08 joschect

@paulgildea This issue was raised by Teams lists app ship build test pass. it is a bit weird if this is by design. It means if user select the option then try to move focus to next element, it always get opposite result. Unless user knew by click tab it will select current focused option therefore if it intends to select A, user must NOT select A in UI but put focus on A then click Tab so it can select A and close the combobox move focus to next element? that seems hard to use?

inateeg avatar Sep 09 '20 22:09 inateeg

@paulgildea @joschect @khmakoto I think the problem here is the onChange function is fired twice if both 'allowFreeForm' and 'multSelect' is enabled. In the onChange function, when we handle updating current selected items, we do not know if it's a select action or an un-select action. Depending on if the changed option is in the selectedKeys, we add/remove the option. If the option changed is in current selected keys, we assume user is trying to remove this selection. While if the option changed is not in current selected keys, we assume user is trying to add this selection. Evoking onChange twice means, (assume we want to select an option) you first add the option into the selectedKeys (correct behavior) then you remove the option from the selectedKeys (un-do the previous step which is not expected). I think the fix should prevent evoking onChange function firing again when tab is pressed. Here is an example showing onChange fired twice: https://codepen.io/ycoco/pen/XWjvZaG?editors=1111

(With allowFreeForm off and multiSelect on, it works as expected and onChange is only fired once. https://codepen.io/ycoco/pen/OJRKQNW)

ycoco avatar Jan 26 '21 22:01 ycoco

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

msft-fluent-ui-bot avatar Jun 25 '21 23:06 msft-fluent-ui-bot