Skip to content

Conversation

@smbadiwe
Copy link
Contributor

Summary

The PR provides a way to solve the problem being discussed at #2591. Currently there's no way to customize the label on TextInput. A common use-case is adding a red asterisk to indicate that a field is required. This PR provides for the label field to also accept a component, thereby solving the problem.

Test Plan

Here's an example of how a custom component can be passed in:

<TextInput
      label={<Text style={{ color: 'red'}}>Must Fill</Text>}
      placeholder='You must fill out this field'
    />

Of course the old usage still works, so this is not a breaking change.

<TextInput
      label='May Fill'
      placeholder='You may not fill out this field'
    />

@callstack-bot
Copy link

callstack-bot commented Nov 28, 2021

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

Copy link
Contributor

@p-syche p-syche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @smbadiwe , thank you very much for this change. It's great you were able to introduce a new functionality without breaking the old.

Your code is good, however I would love to see some PR improvements before approving. Namely I would love to see the new feature added to the TextInput examples and I would appreciate a test checking the function you added for checking label change.

@smbadiwe smbadiwe requested a review from p-syche December 1, 2021 04:39
@smbadiwe smbadiwe requested a review from lukewalczak December 2, 2021 09:56
Copy link
Contributor

@p-syche p-syche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wrote very extensive tests 💪 great job!

LGTM

@p-syche p-syche mentioned this pull request Dec 9, 2021
@lukewalczak lukewalczak merged commit abf631a into callstack:main Dec 10, 2021
@MatthiasD0
Copy link

This change is causing Converting circular structure to JSON error here.
Before the "feature" being added here was already working on our side.
You can not run JSON.stringify on the ReactComponent seen in the screenshot. This is causing the issue here.

Bildschirmfoto 2022-02-04 um 15 24 33

@lukewalczak
Copy link
Member

I think the issue can be fixed on the 4.12.0-alpha.0

@mfds
Copy link

mfds commented Jan 11, 2023

Quick question: was this feature tested with the outlined mode? Doesn't look like there's an example on the example folder and I'm getting weird "glitches" when I try:

Label before animation Label after animation
image image

If you zoom the second picture, you can see the Label label repeated twice. The second one is squished :/

@Rahim-Technyx
Copy link

Rahim-Technyx commented Nov 28, 2024

label={
<Text style={[{ color: 'red', textAlign: 'right' }]}>
{title}

} ---- im trying to align my label text right with style but it is not moving anywhere only the color is getting changed? is there any way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants