( props: LiveRegionProps<Option, IsMulti, Group> )
| 29 | } |
| 30 | |
| 31 | const LiveRegion = < |
| 32 | Option, |
| 33 | IsMulti extends boolean, |
| 34 | Group extends GroupBase<Option> |
| 35 | >( |
| 36 | props: LiveRegionProps<Option, IsMulti, Group> |
| 37 | ) => { |
| 38 | const { |
| 39 | ariaSelection, |
| 40 | focusedOption, |
| 41 | focusedValue, |
| 42 | focusableOptions, |
| 43 | isFocused, |
| 44 | selectValue, |
| 45 | selectProps, |
| 46 | id, |
| 47 | isAppleDevice, |
| 48 | } = props; |
| 49 | |
| 50 | const { |
| 51 | ariaLiveMessages, |
| 52 | getOptionLabel, |
| 53 | inputValue, |
| 54 | isMulti, |
| 55 | isOptionDisabled, |
| 56 | isSearchable, |
| 57 | menuIsOpen, |
| 58 | options, |
| 59 | screenReaderStatus, |
| 60 | tabSelectsValue, |
| 61 | isLoading, |
| 62 | } = selectProps; |
| 63 | const ariaLabel = selectProps['aria-label']; |
| 64 | const ariaLive = selectProps['aria-live']; |
| 65 | |
| 66 | // Update aria live message configuration when prop changes |
| 67 | const messages = useMemo( |
| 68 | () => ({ |
| 69 | ...defaultAriaLiveMessages, |
| 70 | ...(ariaLiveMessages || {}), |
| 71 | }), |
| 72 | [ariaLiveMessages] |
| 73 | ); |
| 74 | |
| 75 | // Update aria live selected option when prop changes |
| 76 | const ariaSelected = useMemo(() => { |
| 77 | let message = ''; |
| 78 | if (ariaSelection && messages.onChange) { |
| 79 | const { |
| 80 | option, |
| 81 | options: selectedOptions, |
| 82 | removedValue, |
| 83 | removedValues, |
| 84 | value, |
| 85 | } = ariaSelection; |
| 86 | // select-option when !isMulti does not return option so we assume selected option is value |
| 87 | const asOption = (val: OnChangeValue<Option, IsMulti>): Option | null => |
| 88 | !Array.isArray(val) ? (val as Option) : null; |
nothing calls this directly
no test coverage detected
searching dependent graphs…