Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
feat: character limit on tags (#9762)
Browse files Browse the repository at this point in the history
* changing

* update all changes

* complete all changes

* Update components/tag/TagsInput.js

* done

* done

---------

Co-authored-by: Eddie Jaoude <[email protected]>
  • Loading branch information
pratik9818 and eddiejaoude authored Nov 28, 2023
1 parent 5441b50 commit eac304e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
40 changes: 35 additions & 5 deletions components/tag/TagsInput.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
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
const { comma, backspace, enter } = {
comma: 188,
backspace: 8,
enter: 13,
};

const maxLength = 32;
const handleKeyUp = (e) => {
const inputValue = inputRef.current.value;
if (e.keyCode === comma || inputValue.endsWith(",") || e.keyCode === enter) {
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) {
return;
Expand Down Expand Up @@ -57,6 +78,15 @@ export default function TagsInput({ tags, onTagAdd, onTagRemove, inputRef }) {

return (
<>
<Notification
show={showNotification.show}
type={showNotification.type}
onClose={() =>
setShowNotification({ ...showNotification, show: false })
}
message={showNotification.message}
additionalMessage={showNotification.additionalMessage}
/>
<label htmlFor="tags">Tags</label>
<ul
role="list"
Expand Down
5 changes: 4 additions & 1 deletion pages/account/manage/event/[[...data]].js
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,12 @@ export default function ManageEvent({ BASE_URL, event }) {
onTagRemove={handleTagRemove}
tags={tags}
inputRef={tagInputRef}
showNotification={showNotification}
setShowNotification={setShowNotification}
/>
<p className="text-sm text-primary-medium-low dark:text-primary-low-high">
Separate tags with commas (tags cannot be duplicated).
Separate tags with commas (tags cannot be duplicated and
max 32 characters).
</p>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion pages/account/manage/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,12 @@ export default function Profile({ BASE_URL, profile, fileExists }) {
onTagRemove={handleTagRemove}
tags={tags}
inputRef={tagInputRef}
showNotification={showNotification}
setShowNotification={setShowNotification}
/>
<p className="text-sm text-primary-medium-low dark:text-primary-low-high">
Separate tags with commas (tags cannot be duplicated).
Separate tags with commas (tags cannot be duplicated and
max 32 characters).
</p>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions pages/docs/how-to-guides/editing-forms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ You can change any of the form fields except `username` as this will always show

![BioDrop Forms page](https://github.com/EddieHubCommunity/BioDrop/assets/82668196/86119a20-412a-449a-acba-87df2510ad25)

5. Maximum 32 characters allowed in each tag , In case you exceed the characters than you can not separate or save the tag by comma.

Note: as you complete these fields the information will appear on the right hand side, which will allow you to preview how your Profile will look.

5. Click `Save`
6. Click `Save`

6. Your changed Profile will be then be available on your custom URL (BioDrop.io/eddiejaoude)
7. Your changed Profile will then be available at your custom URL (BioDrop.io/eddiejaoude)

<Alert
type="warning"
Expand Down

0 comments on commit eac304e

Please sign in to comment.