MCPcopy Create free account
hub / github.com/adobe/react-spectrum / setFocused

Function setFocused

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

Source from the content-addressed store, hash-verified

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

Callers 4

useFocusRingFunction · 0.50
useVisuallyHiddenFunction · 0.50
PromptFieldContainerFunction · 0.50
PromptTokenFieldFunction · 0.50

Calls 3

commitValidationMethod · 0.80
openFunction · 0.70
commitValueFunction · 0.70

Tested by

no test coverage detected