import { DropdownButton } from "./Buttons/DropdownButton"; import { Icons } from "./Icon"; import { TextInputControl, TextInputControlPropsNoLabel, } from "./TextInputs/TextInputControl"; import { useState, useRef, useEffect } from "react"; export interface SearchBarProps extends TextInputControlPropsNoLabel { buttonText?: string; onClick?: () => void; placeholder?: string; } export function SearchBarInput(props: SearchBarProps) { const [dropdownOpen, setDropdownOpen] = useState(false); const [dropdownSelected, setDropdownSelected] = useState("movie"); const dropdownRef = useRef(); const handleClick = (e: MouseEvent) => { if (dropdownRef.current?.contains(e.target as Node)) { // inside click return; } // outside click closeDropdown(); }; const closeDropdown = () => { setDropdownOpen(false); }; return (
setDropdownOpen((old) => !old)} ref={dropdownRef} > {props.buttonText || "Search"}
); }