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

Allowing custom tokenizer token values #168

Merged
merged 3 commits into from
Apr 5, 2016

Conversation

minyoung
Copy link

Typeahead has the formInputOption property, which can be used to transform a complex option to a form input value. It would be nice to have the same thing for Tokenizer.

@@ -103,11 +109,13 @@ var TypeaheadTokenizer = React.createClass({
tokenClasses[this.props.customClasses.token] = !!this.props.customClasses.token;
var classList = classNames(tokenClasses);
var result = this.state.selected.map(function(selected) {
var displayString = this.props.displayOption(selected);
var value = Accessor.valueForOption(this.props.formInputOption, selected);
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think about making it so that the default value for the token is the display string if no formInputOption is set?

@minyoung
Copy link
Author

minyoung commented Apr 5, 2016

Defaulting to Tokenizer.displayOption seems like a reasonable thing to do.
Also updated README.md to include the new Tokenizer.formInputOption

@fmoo
Copy link
Owner

fmoo commented Apr 5, 2016

Thank you SO much for cleaning up this code, also! This is great!

@fmoo fmoo merged commit 5c35e8b into fmoo:master Apr 5, 2016
@fmoo
Copy link
Owner

fmoo commented Apr 5, 2016

Might need to do some post processing on the default if the display value is an HTMLElement instead of text, but we can burn that bridge when we get to it.

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.

2 participants