-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] : 검색어 히스토리 컴포넌트 UI 개선 (#175) #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+60
−45
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { Clock, X } from 'lucide-react'; | ||
| import { Clock, Loader2, X } from 'lucide-react'; | ||
| import { useEffect, useState } from 'react'; | ||
|
|
||
| import useSearchHistoryStore from '@/stores/useSearchHistoryStore'; | ||
|
|
||
|
|
@@ -8,37 +9,48 @@ interface SearchHistoryProps { | |
|
|
||
| export default function SearchHistory({ onHistoryClick }: SearchHistoryProps) { | ||
| const { searchHistory, removeFromHistory } = useSearchHistoryStore(); | ||
| const [isHydrated, setIsHydrated] = useState(false); | ||
|
|
||
| if (searchHistory.length === 0) return null; | ||
| useEffect(() => { | ||
| if (searchHistory.length > 0) { | ||
| setIsHydrated(true); | ||
| } | ||
| }, [searchHistory]); | ||
|
|
||
| return ( | ||
| <div> | ||
| <div className="h-30 overflow-hidden"> | ||
| <div className="flex items-center gap-2"> | ||
| <Clock className="h-4 w-4" /> | ||
| <p className="m-2">최근 검색어</p> | ||
| </div> | ||
| <div className="flex flex-wrap gap-2 pb-4"> | ||
| {searchHistory.slice(10).map((term, index) => ( | ||
| <div | ||
| key={`${term}-${index}`} | ||
| className="bg-background flex items-center gap-2 rounded-full border px-3 py-1.5 text-sm" | ||
| > | ||
| <span | ||
| className="hover:text-primary max-w-30 cursor-pointer truncate text-left" | ||
| onClick={() => onHistoryClick(term)} | ||
| {!isHydrated ? ( | ||
| <div className="flex items-center justify-center py-4"> | ||
| <Loader2 className="h-5 w-5 animate-spin" /> | ||
| </div> | ||
| ) : ( | ||
|
Comment on lines
+12
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. ishydrated tied to history length SearchHistory sets isHydrated to true only when searchHistory.length > 0, so if the persisted store hydrates to an empty array the component can remain stuck showing the spinner forever. This fails the requirement to transition from the pre-hydration spinner to the hydrated UI once Zustand persist hydration completes. Agent Prompt
|
||
| <div className="flex flex-wrap gap-2 pb-4"> | ||
| {searchHistory.slice(0, 10).map((term, index) => ( | ||
| <div | ||
| key={`${term}-${index}`} | ||
| className="bg-background flex items-center gap-2 rounded-full border px-3 py-1.5 text-sm" | ||
| > | ||
| {term} | ||
| </span> | ||
| <span | ||
| className="hover:text-destructive cursor-pointer" | ||
| onClick={() => removeFromHistory(term)} | ||
| title="검색 기록 삭제" | ||
| > | ||
| <X className="h-4 w-4" /> | ||
| </span> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| <span | ||
| className="hover:text-primary max-w-30 cursor-pointer truncate text-left" | ||
| onClick={() => onHistoryClick(term)} | ||
| > | ||
| {term} | ||
| </span> | ||
| <span | ||
| className="hover:text-destructive cursor-pointer" | ||
| onClick={() => removeFromHistory(term)} | ||
| title="검색 기록 삭제" | ||
| > | ||
| <X className="h-4 w-4" /> | ||
| </span> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. ishydrated tied to history
📎 Requirement gap☼ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools