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

Function setFocused

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

Source from the content-addressed store, hash-verified

596
597 let valueOnFocus = useRef([inputValue, displayValue]);
598 let setFocused = (isFocused: boolean) => {
599 if (isFocused) {
600 valueOnFocus.current = [inputValue, displayValue];
601 if (menuTrigger === 'focus' && !props.isReadOnly) {
602 open(null, 'focus');
603 }
604 } else {
605 if (shouldCloseOnBlur) {
606 commitValue();
607 }
608
609 // Commit validation if the input value or selected items changed.
610 if (inputValue !== valueOnFocus.current[0] || displayValue !== valueOnFocus.current[1]) {
611 validation.commitValidation();
612 }
613 }
614
615 setFocusedState(isFocused);
616 };
617
618 let displayedCollection = useMemo(() => {
619 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