From aa7f000fafe70d83656b92b2cfd0543659041a53 Mon Sep 17 00:00:00 2001 From: Nadav Spiegelman Date: Wed, 13 Jul 2016 16:16:59 -0400 Subject: [PATCH] Fix filter for numerical options Prevent a filtering error when allowCreate is true and an option has a numeric label or value. --- examples/src/components/AllowCreate.js | 2 +- src/Select.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/src/components/AllowCreate.js b/examples/src/components/AllowCreate.js index debe56704d..73d729c619 100644 --- a/examples/src/components/AllowCreate.js +++ b/examples/src/components/AllowCreate.js @@ -2,7 +2,7 @@ import React from 'react'; import Select from 'react-select'; const FLAVOURS = [ - { label: 'Chocolate', value: 'chocolate' }, + { label: 'Chocolate', value: 42 }, { label: 'Vanilla', value: 'vanilla' }, { label: 'Strawberry', value: 'strawberry' }, { label: 'Caramel', value: 'caramel' }, diff --git a/src/Select.js b/src/Select.js index 9e96906f62..3b198b827c 100644 --- a/src/Select.js +++ b/src/Select.js @@ -867,7 +867,7 @@ const Select = React.createClass({ let addNewOption = true; //NOTE: only add the "Add" option if none of the options are an exact match filteredOptions.map(option => { - if (option.label.toLowerCase() === filterValue || option.value.toLowerCase() === filterValue) { + if (String(option.label).toLowerCase() === filterValue || String(option.value).toLowerCase() === filterValue) { addNewOption = false; } });