MCPcopy Index your code
hub / github.com/adobe/react-spectrum / setFocused

Function setFocused

packages/react-stately/src/combobox/useComboBoxState.ts:578–596  ·  view source on GitHub ↗
(isFocused: boolean)

Source from the content-addressed store, hash-verified

576
577 let valueOnFocus = useRef([inputValue, displayValue]);
578 let setFocused = (isFocused: boolean) => {
579 if (isFocused) {
580 valueOnFocus.current = [inputValue, displayValue];
581 if (menuTrigger === 'focus' && !props.isReadOnly) {
582 open(null, 'focus');
583 }
584 } else {
585 if (shouldCloseOnBlur) {
586 commitValue();
587 }
588
589 // Commit validation if the input value or selected items changed.
590 if (inputValue !== valueOnFocus.current[0] || displayValue !== valueOnFocus.current[1]) {
591 validation.commitValidation();
592 }
593 }
594
595 setFocusedState(isFocused);
596 };
597
598 let displayedCollection = useMemo(() => {
599 if (triggerState.isOpen) {

Callers 3

useFocusRingFunction · 0.50
useVisuallyHiddenFunction · 0.50
PromptTokenFieldFunction · 0.50

Calls 3

commitValidationMethod · 0.80
openFunction · 0.70
commitValueFunction · 0.70

Tested by

no test coverage detected