From 656cb43eda2b48d4c0a567f0431eaaf8ec392cd8 Mon Sep 17 00:00:00 2001 From: Sebastian Zabielski Date: Wed, 22 May 2024 09:27:38 +0200 Subject: [PATCH] fix(text-input-affix): fix right TextInput.Affix alignment with onPress --- .../TextInput/Adornment/TextInputAffix.tsx | 46 +++++------ .../__snapshots__/TextInput.test.tsx.snap | 77 +++++++++---------- 2 files changed, 58 insertions(+), 65 deletions(-) diff --git a/src/components/TextInput/Adornment/TextInputAffix.tsx b/src/components/TextInput/Adornment/TextInputAffix.tsx index fe6e3daa65..21003968af 100644 --- a/src/components/TextInput/Adornment/TextInputAffix.tsx +++ b/src/components/TextInput/Adornment/TextInputAffix.tsx @@ -153,7 +153,18 @@ const TextInputAffix = ({ const textColor = getTextColor({ theme, disabled }); - const affix = ( + const content = ( + + {text} + + ); + + return ( - - {text} - + {onPress ? ( + + {content} + + ) : ( + content + )} ); - - if (onPress) { - return ( - - {affix} - - ); - } - return affix; }; TextInputAffix.displayName = 'TextInput.Affix'; diff --git a/src/components/__tests__/__snapshots__/TextInput.test.tsx.snap b/src/components/__tests__/__snapshots__/TextInput.test.tsx.snap index 17d37db5db..001888ff95 100644 --- a/src/components/__tests__/__snapshots__/TextInput.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/TextInput.test.tsx.snap @@ -198,61 +198,54 @@ exports[`call onPress when affix adornment pressed 1`] = ` />