Skip to content

Commit

Permalink
fix: Issue #1374 All suggestions are being displayed with scroll area (
Browse files Browse the repository at this point in the history
…#1380)

Signed-off-by: Aryan Singh <114330931+aryanas159@users.noreply.github.com>
  • Loading branch information
aryanas159 authored Jul 18, 2023
1 parent 9716f9a commit 1de56c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
25 changes: 14 additions & 11 deletions components/atoms/Search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { useEffect, useState } from "react";
import { GrClose } from "react-icons/gr";
import { FaSearch } from "react-icons/fa";
import { Spinner } from "../SpinLoader/spin-loader";
import { ScrollArea } from "../ScrollArea/scroll-area";

interface SearchProps {
name: string;
value?: string;
Expand Down Expand Up @@ -83,19 +85,20 @@ const Search = ({
onFocus={() => setShowSuggestions(true)}
onBlur={() => setTimeout(() => setShowSuggestions(false), 500)}
/>

{suggestions && suggestions.length > 0 && showSuggestions && (
<div className="absolute left-0 z-10 w-full pb-1 space-y-1 bg-white border rounded-lg cursor-pointer shadow-input border-light-slate-6 top-full">
{suggestions.map((suggestion, index) => (
<div
className="px-4 py-2 overflow-hidden break-all text-light-slate-9 hover:bg-light-slate-2"
style={suggestionsStyle}
key={index}
onClick={() => handleOnSelect(suggestion)}
>
<span className="pl-5 text-sm ">{suggestion}</span>
</div>
))}
<ScrollArea type="auto" className="h-60">
{suggestions.map((suggestion, index) => (
<div
className="px-4 py-2 overflow-hidden break-all text-light-slate-9 hover:bg-light-slate-2"
style={suggestionsStyle}
key={index}
onClick={() => handleOnSelect(suggestion)}
>
<span className="pl-5 text-sm ">{suggestion}</span>
</div>
))}
</ScrollArea>
</div>
)}

Expand Down
1 change: 0 additions & 1 deletion components/molecules/TableHeader/table-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const TableHeader = ({
if (req.ok) {
const res = await req.json();
const suggestions = res.items.map((item: any) => item.full_name);
if (suggestions.length > 5) suggestions.length = 5;
setSuggestions(suggestions);
}
}, 250);
Expand Down
1 change: 0 additions & 1 deletion components/organisms/InsightPage/InsightPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ const InsightPage = ({ edit, insight, pageRepos }: InsightPageProps) => {
if (req.ok) {
const res = await req.json();
const suggestions = res.items.map((item: any) => item.full_name);
if (suggestions.length > 5) suggestions.length = 5;
setSuggestions(suggestions);
}
}, 250);
Expand Down

0 comments on commit 1de56c7

Please sign in to comment.