From 87b73cb407b0cb01c889af4c89a7e3f7c0ce4aad Mon Sep 17 00:00:00 2001 From: pratik9818 Date: Thu, 23 Nov 2023 22:56:39 +0530 Subject: [PATCH 1/6] changing --- components/tag/TagsInput.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/components/tag/TagsInput.js b/components/tag/TagsInput.js index 4271c17ba25..be2ec02fbbd 100644 --- a/components/tag/TagsInput.js +++ b/components/tag/TagsInput.js @@ -1,7 +1,8 @@ import XMarkIcon from "@heroicons/react/20/solid/XMarkIcon"; import Input from "../form/Input"; +import Notification from "@components/Notification"; -export default function TagsInput({ tags, onTagAdd, onTagRemove, inputRef }) { +export default function TagsInput({ tags, onTagAdd, onTagRemove, inputRef,showNotification, setShowNotification, }) { //key code @@ -10,9 +11,20 @@ export default function TagsInput({ tags, onTagAdd, onTagRemove, inputRef }) { backspace: 8, enter: 13, }; - + const maxLength = 32; const handleKeyUp = (e) => { const inputValue = inputRef.current.value; + if (inputValue.length >= maxLength && e.keyCode !== backspace) { + // '=' sign because in 32 char ',' sign does't count + setShowNotification({ + show: true, + type: "error", + message: "Tag", + additionalMessage: "Tag limit exceeded", + }); + return; + } + if (e.keyCode === comma || inputValue.endsWith(",") || e.keyCode === enter) { const newTag = inputValue.trim().replace(/,/g, ""); if (!newTag) { @@ -57,6 +69,15 @@ export default function TagsInput({ tags, onTagAdd, onTagRemove, inputRef }) { return ( <> + + setShowNotification({ ...showNotification, show: false }) + } + message={showNotification.message} + additionalMessage={showNotification.additionalMessage} + />