MCPcopy
hub / github.com/JedWatson/react-select / focusOption

Function focusOption

packages/react-select/src/__tests__/Select.test.tsx:858–876  ·  view source on GitHub ↗
(
  container: HTMLElement,
  option: Option | OptionNumberValue | OptionBooleanValue,
  options: readonly (Option | OptionNumberValue | OptionBooleanValue)[]
)

Source from the content-addressed store, hash-verified

856);
857
858function focusOption(
859 container: HTMLElement,
860 option: Option | OptionNumberValue | OptionBooleanValue,
861 options: readonly (Option | OptionNumberValue | OptionBooleanValue)[]
862) {
863 let indexOfSelectedOption = options.findIndex(
864 (o) => o.value === option.value
865 );
866
867 for (let i = -1; i < indexOfSelectedOption; i++) {
868 fireEvent.keyDown(container.querySelector('.react-select__menu')!, {
869 keyCode: 40,
870 key: 'ArrowDown',
871 });
872 }
873 expect(
874 container.querySelector('.react-select__option--is-focused')!.textContent
875 ).toEqual(option.label);
876}
877
878cases(
879 'hitting escape on select option',

Callers 1

Select.test.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…