Skip to content

Commit

Permalink
useUniqueId in Autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
Tejas Kumar committed Feb 14, 2019
1 parent ac94baa commit db3eec2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import nanoid from "nanoid"
import * as React from "react"

import ContextMenu from "../ContextMenu/ContextMenu"
import { IContextMenuItem, IContextMenuItem as Item } from "../ContextMenu/ContextMenu.Item"
import { useUniqueId } from "../hooks/useUniqueId"
import Input, { InputProps } from "../Input/Input"
import Progress from "../Progress/Progress"
import styled from "../utils/styled"
Expand Down Expand Up @@ -90,7 +90,7 @@ export function Autocomplete<T>({
...inputProps
}: AutocompleteProps<T>) {
const [isContextMenuOpen, setIsContextMenuOpen] = React.useState(false)
const autocompleteId = React.useRef(id || nanoid())
const uniqueId = useUniqueId(id)

return (
<Container
Expand All @@ -102,7 +102,7 @@ export function Autocomplete<T>({
>
{loading && <Progress bottom />}
<Input
id={autocompleteId.current}
id={uniqueId}
tabIndex={tabIndex}
onFocus={() => setIsContextMenuOpen(true)}
onBlur={() => setIsContextMenuOpen(false)}
Expand Down

0 comments on commit db3eec2

Please sign in to comment.