Skip to content

Commit

Permalink
Update Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgio committed Feb 26, 2023
1 parent 5299337 commit a97058f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/TypeaheadManager.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { KeyboardEvent, useEffect } from 'react';
import usePrevious from '@restart/hooks/usePrevious';
import React, { KeyboardEvent, useEffect, useRef } from 'react';

import { TypeaheadContext, TypeaheadContextType } from './Context';
import {
Expand Down Expand Up @@ -69,7 +68,6 @@ const TypeaheadManager = (props: TypeaheadManagerProps) => {
selectHint,
} = props;

const prevProps = usePrevious(props);
const hintText = getHintText(props);

useEffect(() => {
Expand All @@ -79,11 +77,14 @@ const TypeaheadManager = (props: TypeaheadManagerProps) => {
}
});

const isInitialRender = useRef(true);
useEffect(() => {
if (prevProps && prevProps.isMenuShown !== isMenuShown) {
onMenuToggle(isMenuShown);
if (isInitialRender.current) {
isInitialRender.current = false;
return;
}
});
onMenuToggle(isMenuShown);
}, [isMenuShown, onMenuToggle]);

const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
onKeyDown(e);
Expand Down

0 comments on commit a97058f

Please sign in to comment.