Skip to content

Commit

Permalink
Convert value provided to PhraseValueInput to string to catch Excepti…
Browse files Browse the repository at this point in the history
…on (#45259) (#45365)
  • Loading branch information
kertal authored Sep 11, 2019
1 parent f4b1684 commit 8a535cf
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit 8a535cf

Please sign in to comment.