callstack / react-native-paper

Material Design for React Native (Android & iOS)
https://reactnativepaper.com
MIT License
12.5k stars 2.05k forks source link

Outline line overlaps label #3759

Closed GrandLineAR closed 11 months ago

GrandLineAR commented 1 year ago

Outline line overlaps label

https://user-images.githubusercontent.com/43339997/225590146-615965a0-96f6-41da-b9fb-922dc893ea4c.MP4

Screenshot at Mar 16 14-29-07

"react-native-paper": "^5.4.1"

github-actions[bot] commented 1 year ago

Hey! Thanks for opening the issue. Can you provide a minimal repro which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible. The easiest way to provide a repro is on snack.expo.dev. If it's not possible to repro it on snack.expo.dev, then you can also provide the repro in a GitHub repository.

lukewalczak commented 1 year ago

Hey @GrandLineAR, please provide the snack or attach the code snippet which allow us to reproduce the issue.

jeremyfalldev commented 1 year ago

@lukewalczak We see this issue when we use 'backgroundColor: transparent'.

<TextInput
  mode="outlined"
  label="Name"
  style={{ backgroundColor: 'transparent' }}
/>
lukewalczak commented 1 year ago

@lukewalczak We see this issue when we use 'backgroundColor: transparent'.

Thanks, will take a look into it.

GrandLineAR commented 1 year ago

@lukewalczak We see this issue when we use 'backgroundColor: transparent'.

<TextInput
  mode="outlined"
  label="Name"
  style={{ backgroundColor: 'transparent' }}
/>

Yes, thank you! That's my omission, the documentation mentions that

wavewavewavewave commented 1 year ago

ok, how is there a way to fix this?

lukewalczak commented 1 year ago

I believe we have encountered a limitation of the outlined text input – it will not work well with the patchy background such as an image or gradient.

The issue arises when the input is focused, the label is lifted up to the outline, causing a break in the border. To achieve the desired design, there is rendered label background view, with the same background color as the input, used to cover the border at the point of the break:

<TextInput style={{backgroundColor: 'yellow'}}
image

Passing backgroundColor: 'transparent' into TextInput ends with a missing cover break in the border:

image

To achieve the desired "transparent effect" in the outlined text input, I believe the best approach is to set the input's background color to match the background color of the screen, however this method works seamlessly when the colors are uniform.

I'm going to create a Known issue section in the documentation where that limitation will be mentioned in TextInput component.

Martijncvv commented 1 year ago

I also noticed a slight overlap of the label. image

const outlineStyle: ViewStyle = { borderRadius: styles.radius.large, };

return ( <TextInput mode="outlined" label={label} value={text} outlineStyle={outlineStyle} onChangeText={text => setText(text)} theme={{ colors: { primary: styles.Colors.grey.default, outline: styles.Colors.grey.default } }} /> );

RichardLindhout commented 1 year ago

This can be fixed on the web though with fieldset

RichardLindhout commented 1 year ago

See an old PR for that: https://github.com/callstack/react-native-paper/pull/883 Material UI uses the fieldset trick too :)

Martijncvv commented 1 year ago

Thanks a lot. Do you have an idea how to see the code? The "Files changed" tab of the PR leads to a dead link.

RichardLindhout commented 1 year ago

Yeah @Martijncvv it only works on web so I don't think it's usable since it won't work on iOS/React Native

lelimit commented 11 months ago

It's still a problem in react-native-paper 5.9.1. I got this problem when upgrading react native from 0.71.8 to 0.72.1

AbdurRobTanvir commented 9 months ago

Hi, I am also facing similar kind of issue for the outline line overlapping label when I am increasing the border Width of outline Style in Text Input. In my mobile devices this looks fine but whenever I am running on Tablet the following issue is occurring where a line is visible under the label.

Capture above image is what Tablet is showing.

Capture11 above image is what mobile is showing.

image This is the code for outline style.

robertcabrera4871 commented 9 months ago

I am still seeing this issue after the PR

redbluenat commented 8 months ago

The issue still exists in: "react-native-paper": "5.11.1",

It is related to the custom label text component. For string, it works okay.

ravithoria commented 4 months ago

Still facing issue in: react-native-paper: 5.12.3

JoshCarse commented 1 month ago

Yeah still getting issue in: "react-native-paper": "5.12.3". Only when using custom label component as @redbluenat mentioned. Using string for label works fine but I need to use custom label component.