added support for creating tags with space or enter keys

This commit is contained in:
Pramod Mahajan 2025-05-26 13:33:18 +05:30
parent 7ff4280b4d
commit 35ca496166

View File

@ -60,7 +60,7 @@ useEffect(() => {
}; };
const handleInputKeyDown = (e) => { const handleInputKeyDown = (e) => {
if (e.key === "Enter" && input.trim() !== "") { if ((e.key === "Enter" || e.key === " ") || trimmedInput !== "") {
e.preventDefault(); e.preventDefault();
const existing = options.find( const existing = options.find(
(opt) => opt.name.toLowerCase() === input.trim().toLowerCase() (opt) => opt.name.toLowerCase() === input.trim().toLowerCase()