From 1ad6de4ee75041129a657b92931a2965a1805c31 Mon Sep 17 00:00:00 2001 From: kosciolek <45483493+kosciolek@users.noreply.github.com> Date: Mon, 31 Oct 2022 03:20:05 +0100 Subject: [PATCH] Correct SR message when focusing an option (#5084) --- .changeset/forty-needles-flash.md | 5 +++++ packages/react-select/src/components/LiveRegion.tsx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/forty-needles-flash.md diff --git a/.changeset/forty-needles-flash.md b/.changeset/forty-needles-flash.md new file mode 100644 index 0000000000..0060fc5804 --- /dev/null +++ b/.changeset/forty-needles-flash.md @@ -0,0 +1,5 @@ +--- +'react-select': patch +--- + +When focusing a dropdown option, the numbers included in the aria live region take filtering into consideration. diff --git a/packages/react-select/src/components/LiveRegion.tsx b/packages/react-select/src/components/LiveRegion.tsx index 1f6fe694c8..a22b133da6 100644 --- a/packages/react-select/src/components/LiveRegion.tsx +++ b/packages/react-select/src/components/LiveRegion.tsx @@ -121,7 +121,7 @@ const LiveRegion = < label: getOptionLabel(focused), isDisabled: isOptionDisabled(focused, selectValue), isSelected, - options, + options: focusableOptions, context: focused === focusedOption ? ('menu' as const) : ('value' as const), selectValue, @@ -136,7 +136,7 @@ const LiveRegion = < getOptionLabel, isOptionDisabled, messages, - options, + focusableOptions, selectValue, ]);