fix: SuggestionsModal now fetches fresh suggestions every time
Bug: SuggestionsModal only fetched on first open because it checked if suggestions.length === 0 before fetching. This meant changing the prompt and re-opening the modal showed stale suggestions. Fix: useEffect now: - Clears suggestions and error on every open - Always fetches fresh suggestions when isOpen changes - Also re-fetches when userInput changes while modal is open - Dependency array: [isOpen, userInput] Result: Every click of 'Get Suggestions' generates new, relevant suggestions based on the current prompt.
This commit is contained in:
1 parent
a713488fb7
commit
fe6ec467c6
1 file changed
+5
-3
@@ -35,12 +35,14 @@ export default function SuggestionsModal({ isOpen, onClose, onSelect, userInput
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-fetch when opened
|
||||
// Auto-fetch when opened — always fetch fresh suggestions
|
||||
useEffect(() => {
|
||||
if (isOpen && suggestions.length === 0 && !loading && !error) {
|
||||
if (isOpen) {
|
||||
setSuggestions([])
|
||||
setError('')
|
||||
fetchSuggestions()
|
||||
}
|
||||
}, [isOpen])
|
||||
}, [isOpen, userInput])
|
||||
|
||||
if (!isOpen) return null
|
||||
|
||||
|
||||
Reference in new issue
Block a user