Skip to content

Commit 9f22f37

Browse files
committed
Added Enter to search functionality in posts page
1 parent f6ec8d1 commit 9f22f37

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

frontend/src/pages/Posts.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const Posts = () => {
7777

7878
const handleSearch = () => {
7979
fetchPosts(page, 12, searchQuery, filterTags);
80+
// console.log(searchQuery)
8081
};
8182

8283
if (loading) {
@@ -165,7 +166,12 @@ const Posts = () => {
165166
onChange={(e) => setSearchQuery(e.target.value)}
166167
placeholder="🔍 Search anything"
167168
className="p-2 w-full max-w-xs rounded-md text-[#000435] bg-white dark:text-white dark:bg-[#000435] border border-sky-400 focus:outline-none focus:ring-2 focus:ring-blue-500"
168-
/>
169+
onKeyDown={(event)=>{
170+
if(event.key == "Enter"){
171+
handleSearch()
172+
}
173+
}}
174+
/>
169175
<button
170176
onClick={handleSearch}
171177
className="bg-blue-500 text-white px-4 py-2 rounded ml-2 hover:bg-blue-600 transition-colors duration-200"

0 commit comments

Comments
 (0)