Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Not Show Content When style both set borderWidth and backgroundColor. #45938

Open
zdpdsy opened this issue Aug 8, 2024 · 11 comments · May be fixed by #45972
Open

Text Not Show Content When style both set borderWidth and backgroundColor. #45938

zdpdsy opened this issue Aug 8, 2024 · 11 comments · May be fixed by #45972
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@zdpdsy
Copy link

zdpdsy commented Aug 8, 2024

Description

Text Not Show Content When style both set borderWidth and backgroundColor.
if Text style is styles.tag, the '预售' Not Show,only show backgroundColor
else style is styles.tag, the '停止营业' Can show normally
like this
image

The Code:

image

style class:
image

Code link: https://github.com/zdpdsy/reproducer/blob/main/ReproducerApp/App.tsx

Steps to reproduce

1.cd ReproducerApp
2. npm run start
3. run Xcode

React Native Version

0.73.9

Affected Platforms

Runtime - iOS

Areas

Fabric - The New Renderer

Output of npx react-native info

Node Version : v20.11.1

Stacktrace or Logs

none log

Reproducer

https://github.com/zdpdsy/reproducer

@zdpdsy zdpdsy added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Aug 8, 2024
@cortinico cortinico added Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. and removed Needs: Triage 🔍 labels Aug 8, 2024
@netmaxt3r
Copy link
Contributor

@zdpdsy issue lists rn version 0.73.9 but reproducer is on 0.74.5, I am not able to reproduce the issue on reproducer, please confirm from your side

@zdpdsy
Copy link
Author

zdpdsy commented Aug 9, 2024

@zdpdsy issue lists rn version 0.73.9 but reproducer is on 0.74.5, I am not able to reproduce the issue on reproducer, please confirm from your side

@netmaxt3r sorry,i push code now. can you try it again? thank you!
The Result Snapshot is
image

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Aug 9, 2024
@cortinico cortinico removed the Needs: Attention Issues where the author has responded to feedback. label Aug 9, 2024
@netmaxt3r
Copy link
Contributor

@zdpdsy thanks for update, i see that this is fabric related issue. issue is reproducible on current latest rn 0.74.5 with fabric enabled , i was wrong on previous comment i was on old architecture when i said i was not able to reproduce on 0.74.5 sorry about that

@cortinico
Copy link
Contributor

@zdpdsy thanks for update, i see that this is fabric related issue. issue is reproducible on current latest rn 0.74.5 with fabric enabled , i was wrong on previous comment i was on old architecture when i said i was not able to reproduce on 0.74.5 sorry about that

Thanks for the confirmation @netmaxt3r

@shubhamguptadream11
Copy link
Contributor

@zdpdsy This is fabric related issue. I'm trying to debug this issue.
In Fabric New Renderer:

static UIImage *RCTGetSolidBorderImage(

This is responsible for drawing backgroundColor and borderWidth styles.

I am looking to map same for Old Architecture. @cortinico Can you help me pointing the code responsible for handling border and backgroundColor for Old Architecture?
This will help me in finding the root cause.

@zdpdsy
Copy link
Author

zdpdsy commented Aug 9, 2024

@zdpdsy thanks for update, i see that this is fabric related issue. issue is reproducible on current latest rn 0.74.5 with fabric enabled , i was wrong on previous comment i was on old architecture when i said i was not able to reproduce on 0.74.5 sorry about that

OK,Thanks,i find a temporary solution is change border style To Super element Like as ,like th snapShot:

image

but this solution is temporary,can't Real problem solving。

@netmaxt3r
Copy link
Contributor

@shubhamguptadream11 issue might not be on that function , since it is reproducible with dotted border style as well probably with layer zIndex for border layer and main layer.

@netmaxt3r
Copy link
Contributor

I have found one more issue related to this when border width is not specified or computed to zero with dotted style we loose background color

 <Text style={{ 
        backgroundColor: '#F00',
        borderWidth: 0, 
        borderStyle: 'dotted'
    }}>hello</Text>

this is due to early return without checking bgcolor

if (lineWidth <= 0.0) {
return nil;
}

@shubhamguptadream11
Copy link
Contributor

@netmaxt3r I found one more issue related to border in Text Component only.
Here: #45925

@netmaxt3r
Copy link
Contributor

I did some comparison with old and new arch implementation, i see border styling is not working properly even on old arch

     <View style={{ 
        backgroundColor: '#F00',
        borderColor: "black",
        borderWidth: 1,
        borderStyle: "dashed",
        minHeight: 30,
      }}/>
      <Text
      style={{ 
        backgroundColor: '#F00',
        borderColor: "black",
        borderWidth: 1,
        borderStyle: "dashed",
        minHeight: 30,
        marginTop: 10,
      }}
      >hello</Text>
image

text view render with solid border rather than dashed

I also see in the new arch RCTTextView has been replaced by RCTParagraphComponentView with improved logic for border rendering. i see now we render border and background on single CALayer and setting its zIndex to -1024 hopping it would render borderLayer behind the root layer of RCTParagraphComponentView, but it is not , you can verify this by applying some transparency to border layer (zindex works with relative to multiple sublayers). I am not sure issue is with iOS or RN, I believe we might have to reconsider the logic for border and background layer
@cortinico since TextView is a extremely important component can we have someone from meta team take a look and suggest a way forward
possible options i see are

  • move rendering text to new sub layer and add on top of borderLayer
  • separate border and background.

@zhongwuzw
Copy link
Contributor

Any one can try this #45972 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants