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

Label only accepting a string. #31

Closed
wkerswell opened this issue Oct 27, 2015 · 6 comments
Closed

Label only accepting a string. #31

wkerswell opened this issue Oct 27, 2015 · 6 comments

Comments

@wkerswell
Copy link
Contributor

I would like to pass in a tooltip as a node for my label but looking at the source code the label propType is set to a string. Would we be able to change it to accept and object as well?

<Input
  name="cvv"
  label={<OverlayTrigger placement='top' overlay={<Tooltip><strong>Holy guacamole!</strong></Tooltip>}><p>Check this info.</p></OverlayTrigger>}
  type="text"
  value={this.props.cvv}
  />
@wkerswell
Copy link
Contributor Author

I did think It might be as easy as changing the label propType to label: React.PropTypes.node but this is producing an error.

Uncaught TypeError: Converting circular structure to JSON

@wkerswell
Copy link
Contributor Author

I have tested this by just using the BS Input which works. Think something else is going here.

@wkerswell
Copy link
Contributor Author

So in the component.js mixin there is a getId function which is trying to do a hash of stringifyed props.
this.hashString(JSON.stringify(this.props)
The props has a circular structure so cannot be stringifyed when we pass in a node. By just supplying an ID props the function wont run this code and I can use a node. Wondering if we need to make some changes to not call stringify on the props.

@twisty
Copy link
Owner

twisty commented Nov 2, 2015

Relaxed this constraint in 0433c8d. Thanks for the PR!

Now that labels can contain any React "renderable content", the onus is on the developer to ensure they pass in valid content. For example, block content (like <p>) isn't allowed in a <label>. 😉

For future reference (when I eventually write some docs): the label spec.

@twisty twisty closed this as completed Nov 2, 2015
@wkerswell
Copy link
Contributor Author

Yeah just threw the <p> in for testing as it needed to be in a single element. Then realised the error of my way and changed it 😛

Did you update npm?

@twisty
Copy link
Owner

twisty commented Nov 2, 2015

Just updated...

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

No branches or pull requests

2 participants