From f3a09b71b7496f77160f9c711eed75eb4a919546 Mon Sep 17 00:00:00 2001 From: Sravaani <140899293+Sravaani@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:58:01 +0530 Subject: [PATCH] Resolved Search bar closing issue --- src/Components/Search.jsx | 21 ++++++++++++++++----- src/layouts/sidebar/SubMenu.jsx | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Components/Search.jsx b/src/Components/Search.jsx index a8bfead..06e3433 100644 --- a/src/Components/Search.jsx +++ b/src/Components/Search.jsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import { subMenusList } from '../Constants'; import {CiSearch } from "react-icons/ci"; import { AiOutlineDoubleRight } from "react-icons/ai"; @@ -6,6 +6,7 @@ import { NavLink } from 'react-router-dom'; const Search = () => { const [searchInput, setSearchInput] = useState(""); + const [isSearchBarOpen, setIsSearchBarOpen] = useState(false); const handleChange = (e) => { e.preventDefault(); setSearchInput(e.target.value); @@ -13,7 +14,17 @@ const Search = () => { const filteredContent = subMenusList.filter(menu => { const content = menu.title.toLowerCase(); return content.includes(searchInput.toLowerCase()); - }) + }); + + const selectOption = (name) => { + setSearchInput(name); + setIsSearchBarOpen(false) + }; + + // useEffect(() => { + // setSearchInput(""); + // },[selectOption]) + return ( <>