Add @mention autocomplete in task description 馃懃
File: client/src/components/Task/TaskModal.jsx
You can type @name but nothing happens 馃拃
No autocomplete, no suggestions fr!!
Fix: show suggestion dropdown when @ typed:
const [mentionQuery, setMentionQuery] = useState('')
const [showSuggestions, setShowSuggestions] = useState(false)
const handleDescChange = (e) => {
const val = e.target.value
setForm({...form, description: val})
const lastWord = val.split(' ').pop()
if (lastWord.startsWith('@')) {
setMentionQuery(lastWord.slice(1))
setShowSuggestions(true)
} else {
setShowSuggestions(false)
}
}
// hardcode team members for now:
const TEAM = ['anoopcodehack', 'phisher01', 'omkarwarik02']
const suggestions = TEAM.filter(m =>
m.includes(mentionQuery)
)
{showSuggestions && suggestions.length > 0 && (
{suggestions.map(s => (
{
const words = form.description.split(' ')
words[words.length-1] = `@${s} `
setForm({...form, description: words.join(' ')})
setShowSuggestions(false)
}}
className="block w-full text-left px-3 py-2
text-xs text-[#888] hover:bg-[#2a2a2f]">
@{s}
))}
)}
~20 lines! No backend needed 馃幆
Add @mention autocomplete in task description 馃懃
File: client/src/components/Task/TaskModal.jsx
You can type @name but nothing happens 馃拃
No autocomplete, no suggestions fr!!
Fix: show suggestion dropdown when @ typed:
const [mentionQuery, setMentionQuery] = useState('')
const [showSuggestions, setShowSuggestions] = useState(false)
const handleDescChange = (e) => {
const val = e.target.value
setForm({...form, description: val})
const lastWord = val.split(' ').pop()
if (lastWord.startsWith('@')) {
setMentionQuery(lastWord.slice(1))
setShowSuggestions(true)
} else {
setShowSuggestions(false)
}
}
// hardcode team members for now:
const TEAM = ['anoopcodehack', 'phisher01', 'omkarwarik02']
const suggestions = TEAM.filter(m =>
m.includes(mentionQuery)
)
{showSuggestions && suggestions.length > 0 && (
~20 lines! No backend needed 馃幆