From e2cfad582fcdbb096ebb006000345f2011371c64 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Wed, 11 Sep 2024 08:28:19 +0200 Subject: [PATCH] feat(StringInputWithCharacterCount): handle plural form --- studio/components/StringInputWithCharacterCount.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/studio/components/StringInputWithCharacterCount.tsx b/studio/components/StringInputWithCharacterCount.tsx index 852581088..fa674376e 100644 --- a/studio/components/StringInputWithCharacterCount.tsx +++ b/studio/components/StringInputWithCharacterCount.tsx @@ -10,13 +10,16 @@ export const StringInputWithCharacterCount = ({ ...defaultProps }: StringInputWithCharacterCountProps) => { const characterCount = defaultProps.value?.length ?? 0; + const isPlural = + (maxCount !== undefined && maxCount !== 1) || + (maxCount === undefined && characterCount !== 1); return ( {defaultProps.renderDefault(defaultProps)} {characterCount} - {maxCount && `/${maxCount}`} characters + {maxCount && `/${maxCount}`} character{isPlural ? "s" : ""} );