From 6795a72e50b5789ab21800b63328c3b84a21ec29 Mon Sep 17 00:00:00 2001 From: Julius Osokinas Date: Tue, 9 Feb 2021 15:54:44 +0000 Subject: [PATCH] fix: make sure auto identificator gets generated Co-Authored-By: Andre Luiz Rabello --- packages/react/src/components/input/input.tsx | 6 ++---- packages/react/src/components/textarea/textarea.tsx | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/react/src/components/input/input.tsx b/packages/react/src/components/input/input.tsx index 28c4e6624..134ba0caf 100644 --- a/packages/react/src/components/input/input.tsx +++ b/packages/react/src/components/input/input.tsx @@ -18,10 +18,8 @@ export const Input = withRef( }: InputProps, ref: InputProps['ref'] ): JSX.Element => { - const [autoId] = useState(() => - children ? `${idPrefix}_${++idCount}` : undefined - ); - const id = externalId || autoId; + const [autoId] = useState(() => `${idPrefix}_${++idCount}`); + const id = externalId || (children ? autoId : undefined); return ( diff --git a/packages/react/src/components/textarea/textarea.tsx b/packages/react/src/components/textarea/textarea.tsx index d92ffc285..62843b521 100755 --- a/packages/react/src/components/textarea/textarea.tsx +++ b/packages/react/src/components/textarea/textarea.tsx @@ -20,10 +20,8 @@ export const Textarea = withRef( }: TextareaProps, ref: TextareaProps['ref'] ): JSX.Element => { - const [autoId] = useState(() => - children ? `${idPrefix}_${++idCount}` : undefined - ); - const id = externalId || autoId; + const [autoId] = useState(() => `${idPrefix}_${++idCount}`); + const id = externalId || (children ? autoId : undefined); return (