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

Convert value provided to PhraseValueInput to string to prevent Exception with numeric values #45259

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class PhraseValueInputUI extends PhraseSuggestor<Props> {
private renderWithSuggestions() {
const { suggestions } = this.state;
const { value, intl, onChange } = this.props;
const options = value ? uniq([value, ...suggestions]) : suggestions;
// there are cases when the value is a number, this would cause an exception
const valueAsStr = String(value);
const options = value ? uniq([valueAsStr, ...suggestions]) : suggestions;
return (
<StringComboBox
placeholder={intl.formatMessage({
Expand All @@ -69,7 +71,7 @@ class PhraseValueInputUI extends PhraseSuggestor<Props> {
})}
options={options}
getLabel={option => option}
selectedOptions={value ? [value] : []}
selectedOptions={value ? [valueAsStr] : []}
onChange={([newValue = '']) => onChange(newValue)}
onSearchChange={this.onSearchChange}
singleSelection={{ asPlainText: true }}
Expand Down