From c3a2dbd025ced92d0e2b8e690eb41b23be28eae5 Mon Sep 17 00:00:00 2001 From: Tomasz Janiczek Date: Wed, 2 Aug 2023 09:49:08 +0200 Subject: [PATCH] fix: use theme background for transparent text inputs (#3980) Co-authored-by: Tomasz Janiczek --- src/components/TextInput/Label/InputLabel.tsx | 1 + .../TextInput/Label/LabelBackground.tsx | 2 ++ .../TextInput/TextInputOutlined.tsx | 7 ++++- src/components/__tests__/TextInput.test.tsx | 29 ++++++++++++++++++- .../__snapshots__/TextInput.test.tsx.snap | 1 + 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/components/TextInput/Label/InputLabel.tsx b/src/components/TextInput/Label/InputLabel.tsx index 0289bdc76c..a2d8d7845a 100644 --- a/src/components/TextInput/Label/InputLabel.tsx +++ b/src/components/TextInput/Label/InputLabel.tsx @@ -122,6 +122,7 @@ const InputLabel = (props: InputLabelProps) => { backgroundColor, roundness, maxFontSizeMultiplier: maxFontSizeMultiplier, + testID, })} { const opacity = labeled.interpolate({ inputRange: [0, 0.6], @@ -60,6 +61,7 @@ const LabelBackground = ({ roundedEdgeCover, { }) ); +it("correctly applies theme background to label when input's background is transparent", () => { + const backgroundColor = 'transparent'; + const theme = { + ...DefaultTheme, + colors: { + ...DefaultTheme.colors, + background: 'pink', + }, + }; + + const { getByTestId } = render( + + + + ); + + expect(getByTestId('transparent-example-label-background')).toHaveStyle({ + backgroundColor: 'pink', + }); +}); + describe('maxFontSizeMultiplier', () => { const createInput = ( type: Exclude, diff --git a/src/components/__tests__/__snapshots__/TextInput.test.tsx.snap b/src/components/__tests__/__snapshots__/TextInput.test.tsx.snap index f2e8dcc77f..fed887da57 100644 --- a/src/components/__tests__/__snapshots__/TextInput.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/TextInput.test.tsx.snap @@ -695,6 +695,7 @@ exports[`correctly applies height to multiline Outline TextInput 1`] = ` "writingDirection": "ltr", } } + testID="text-input-outlined-label-background" > Outline Input