From 0a1b1eb70a2d97785ed955580cc50b4c3a6347b7 Mon Sep 17 00:00:00 2001 From: James Morris Date: Thu, 4 Aug 2022 13:26:55 +0100 Subject: [PATCH] Added in the max length counter for the bio modal refs https://github.com/TryGhost/Team/issues/1716 --- .../src/components/modals/AddDetailsDialog.js | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/apps/comments-ui/src/components/modals/AddDetailsDialog.js b/apps/comments-ui/src/components/modals/AddDetailsDialog.js index 80a515871a..190ea6b84e 100644 --- a/apps/comments-ui/src/components/modals/AddDetailsDialog.js +++ b/apps/comments-ui/src/components/modals/AddDetailsDialog.js @@ -11,6 +11,9 @@ const AddNameDialog = (props) => { const [name, setName] = useState(member.name ?? ''); const [bio, setBio] = useState(member.bio ?? ''); + const maxBioCharsLeft = 50; + const [bioCharsLeft, setBioCharsLeft] = useState(maxBioCharsLeft); + const [error, setError] = useState({name: '', bio: ''}); const close = (succeeded) => { @@ -101,28 +104,20 @@ const AddNameDialog = (props) => { }
- -
{error.bio}
-
+
{bioCharsLeft} characters left
{ - setBio(e.target.value); + let bioText = e.target.value; + setBioCharsLeft(maxBioCharsLeft - bioText.length); + setBio(bioText); }} onKeyDown={(e) => { if (e.key === 'Enter') {