Skip to content

Commit

Permalink
Replace handleTriggerFocus → setDropdownOpenRef
Browse files Browse the repository at this point in the history
  • Loading branch information
acusti committed Dec 28, 2023
1 parent 2204491 commit 254fc34
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/dropdown/src/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export default function Dropdown({
const mouseDownPositionRef = useRef<MousePosition | null>(null);
const outOfBounds = useIsOutOfBounds(dropdownBodyElement);

const setDropdownOpenRef = useRef(() => setIsOpen(true));
const allowCreateRef = useRef(allowCreate);
const allowEmptyRef = useRef(allowEmpty);
const hasItemsRef = useRef(hasItems);
Expand Down Expand Up @@ -618,10 +619,6 @@ export default function Dropdown({
[closeDropdown, isOpenOnMount, isTriggerFromProps],
);

const handleTriggerFocus = useCallback(() => {
setIsOpen(true);
}, []);

if (!isTriggerFromProps) {
if (isSearchable) {
trigger = (
Expand All @@ -630,7 +627,7 @@ export default function Dropdown({
disabled={disabled}
initialValue={value ?? ''}
name={name}
onFocus={handleTriggerFocus}
onFocus={setDropdownOpenRef.current}
placeholder={placeholder}
ref={inputElementRef}
selectTextOnFocus
Expand Down

0 comments on commit 254fc34

Please sign in to comment.