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

Commit eac304e

Browse files
feat: character limit on tags (#9762)
* changing * update all changes * complete all changes * Update components/tag/TagsInput.js * done * done --------- Co-authored-by: Eddie Jaoude <[email protected]>
1 parent 5441b50 commit eac304e

File tree

4 files changed

+47
-9
lines changed

4 files changed

+47
-9
lines changed

components/tag/TagsInput.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
11
import XMarkIcon from "@heroicons/react/20/solid/XMarkIcon";
22
import Input from "../form/Input";
3+
import Notification from "@components/Notification";
34

4-
export default function TagsInput({ tags, onTagAdd, onTagRemove, inputRef }) {
5-
6-
5+
export default function TagsInput({
6+
tags,
7+
onTagAdd,
8+
onTagRemove,
9+
inputRef,
10+
showNotification,
11+
setShowNotification,
12+
}) {
713
//key code
814
const { comma, backspace, enter } = {
915
comma: 188,
1016
backspace: 8,
1117
enter: 13,
1218
};
13-
19+
const maxLength = 32;
1420
const handleKeyUp = (e) => {
1521
const inputValue = inputRef.current.value;
16-
if (e.keyCode === comma || inputValue.endsWith(",") || e.keyCode === enter) {
22+
if (inputValue.length >= maxLength && e.keyCode !== backspace) {
23+
// '=' sign because in 32 char ',' sign does't count
24+
setShowNotification({
25+
show: true,
26+
type: "error",
27+
message: "Tag",
28+
additionalMessage: "Tag limit exceeded",
29+
});
30+
return;
31+
}
32+
33+
if (
34+
e.keyCode === comma ||
35+
inputValue.endsWith(",") ||
36+
e.keyCode === enter
37+
) {
1738
const newTag = inputValue.trim().replace(/,/g, "");
1839
if (!newTag) {
1940
return;
@@ -57,6 +78,15 @@ export default function TagsInput({ tags, onTagAdd, onTagRemove, inputRef }) {
5778

5879
return (
5980
<>
81+
<Notification
82+
show={showNotification.show}
83+
type={showNotification.type}
84+
onClose={() =>
85+
setShowNotification({ ...showNotification, show: false })
86+
}
87+
message={showNotification.message}
88+
additionalMessage={showNotification.additionalMessage}
89+
/>
6090
<label htmlFor="tags">Tags</label>
6191
<ul
6292
role="list"

pages/account/manage/event/[[...data]].js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,12 @@ export default function ManageEvent({ BASE_URL, event }) {
341341
onTagRemove={handleTagRemove}
342342
tags={tags}
343343
inputRef={tagInputRef}
344+
showNotification={showNotification}
345+
setShowNotification={setShowNotification}
344346
/>
345347
<p className="text-sm text-primary-medium-low dark:text-primary-low-high">
346-
Separate tags with commas (tags cannot be duplicated).
348+
Separate tags with commas (tags cannot be duplicated and
349+
max 32 characters).
347350
</p>
348351
</div>
349352
</div>

pages/account/manage/profile.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,12 @@ export default function Profile({ BASE_URL, profile, fileExists }) {
251251
onTagRemove={handleTagRemove}
252252
tags={tags}
253253
inputRef={tagInputRef}
254+
showNotification={showNotification}
255+
setShowNotification={setShowNotification}
254256
/>
255257
<p className="text-sm text-primary-medium-low dark:text-primary-low-high">
256-
Separate tags with commas (tags cannot be duplicated).
258+
Separate tags with commas (tags cannot be duplicated and
259+
max 32 characters).
257260
</p>
258261
</div>
259262
</div>

pages/docs/how-to-guides/editing-forms.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ You can change any of the form fields except `username` as this will always show
2828

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

31+
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.
32+
3133
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.
3234

33-
5. Click `Save`
35+
6. Click `Save`
3436

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

3739
<Alert
3840
type="warning"

0 commit comments

Comments
 (0)