Skip to content

Commit

Permalink
fix: race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
MounirDhahri committed Nov 26, 2024
1 parent a0a096b commit 5b71ff2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/Components/GlobalSearchInput/GlobalSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Flex, RoundSearchInput, Touchable } from "@artsy/palette-mobile"
import { GlobalSearchInputOverlay } from "app/Components/GlobalSearchInput/GlobalSearchInputOverlay"
import { useDismissSearchOverlayOnTabBarPress } from "app/Components/GlobalSearchInput/utils/useDismissSearchOverlayOnTabBarPress"
import { ICON_HIT_SLOP } from "app/Components/constants"
import { useDebouncedValue } from "app/utils/hooks/useDebouncedValue"
import { forwardRef, Fragment, useImperativeHandle, useState } from "react"
import { useTracking } from "react-tracking"

Expand All @@ -16,13 +17,14 @@ export type GlobalSearchInput = {
export const GlobalSearchInput = forwardRef<GlobalSearchInput, GlobalSearchInputProps>(
({ ownerType }, ref) => {
const [isVisible, setIsVisible] = useState(false)
const debouncedIsVisible = useDebouncedValue({ value: isVisible })
const tracking = useTracking()

useDismissSearchOverlayOnTabBarPress({ isVisible, ownerType, setIsVisible })

useImperativeHandle(ref, () => ({
focus: () => {
if (!isVisible) {
if (!debouncedIsVisible.debouncedValue) {
setIsVisible(true)
}
},
Expand Down

0 comments on commit 5b71ff2

Please sign in to comment.