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

fix(text-input-label-background): custom component background height #4442

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

seb-zabielski
Copy link
Contributor

@seb-zabielski seb-zabielski commented Jun 24, 2024

Motivation

Label with nested text components are displayed twice.

Previously, to calculate the background of a label, the label itself was rendered and the color of its text was set to transparent. Everything worked for the label as a string or a single element. For nested components, setting color: "transparent" didn't work and the text was duplicated (nested text color was not set as transparent). This pull request changes the way to get the right shape, as we already store the height of the label. Instead of rendering the label, we simply use the height value.

Related issue

#4441

Test plan

Run example app and use label from the related issue or example below

<TextInput
  mode="outlined"
  label={
    <Text style={{ color: 'red' }}>
      First <Text style={{ color: 'blue' }}>Second</Text>
    </Text>
  }
  placeholder="Type something"
  value={outlinedText}
  onChangeText={(outlinedText) =>
    inputActionHandler('outlinedText', outlinedText)
  }
/>
BEFORE AFTER
image image
Red "First" is not duplicated, but blue "Second" is displayed twice. Second one is a tiny one The label is not duplicated. The background has not changed

@seb-zabielski seb-zabielski requested a review from gedu June 24, 2024 15:32
@callstack-bot
Copy link

callstack-bot commented Jun 24, 2024

Hey @seb-zabielski, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

@gedu gedu added this to the 5.12.4 milestone Jun 25, 2024
@gedu
Copy link
Contributor

gedu commented Jun 25, 2024

Does this work even if I wrap the Text with View or Fragment

@seb-zabielski
Copy link
Contributor Author

Fragment yes.
For View background also yes, but in this case label itself isn't positioned correctly. Position of the label is not related to this PR and it looks the same without this fix.

Fragment View
image image

@gedu
Copy link
Contributor

gedu commented Jun 25, 2024

Awesome, just wanna double, we have at least 2 workarounds for now, thanks

@lukewalczak lukewalczak force-pushed the fix/label-background branch from 4977fc8 to 8137629 Compare July 27, 2024 12:32
@lukewalczak lukewalczak merged commit d9db02e into callstack:main Jul 27, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants