downshift-js / downshift

🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.
http://downshift-js.com/
MIT License
12.05k stars 933 forks source link

Screen readers read out object code when using useMultipleSelection hook #1594

Open jamesryan-dev opened 5 months ago

jamesryan-dev commented 5 months ago

Relevant code or config

But if present here in your docs so I have only included this:

https://www.downshift-js.com/use-multiple-selection/

What you did:

We are using the removeSelectedItem function which is causing this screen reader issue I believe

What happened:

You will hear, "[object, object] has been removed"

Problem description:

Screen readers are reading out code

Suggested solution:

I'm not sure sorry

jamesryan-dev commented 3 months ago

any updates on this?

ApplyBoardDak commented 4 weeks ago

this also happens on Downshift v8. the removeSelectedItem will read [object object] if useMultipleSelection uses an object as its type instead of a string. in v7 and v8 you can get around this by implementing getA11yRemovalMessage like so:

  const { getSelectedItemProps, getDropdownProps, removeSelectedItem, reset } =
    useMultipleSelection<OptionWithGroup>({
      getA11yRemovalMessage: (options) => {
        return `${options.removedSelectedItem.label} has been removed`
      },
      ...