From a747debd181d2b3d72e1da6ce71468780e599b9c Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Tue, 30 Oct 2018 20:11:33 -0500 Subject: [PATCH] fix: clear Select when value prop becomes null --- package/src/components/Select/v1/Select.js | 2 +- package/src/components/Select/v1/Select.test.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package/src/components/Select/v1/Select.js b/package/src/components/Select/v1/Select.js index 523243dfe..f353b261b 100644 --- a/package/src/components/Select/v1/Select.js +++ b/package/src/components/Select/v1/Select.js @@ -573,7 +573,7 @@ class Select extends Component { passthroughProps[prop] = this.props[prop]; }); - let optionValue; + let optionValue = null; if (value !== undefined && value !== null) { optionValue = reactSelectOptions.find((opt) => { if (opt.options) return opt.options.find((o) => o.value === value); diff --git a/package/src/components/Select/v1/Select.test.js b/package/src/components/Select/v1/Select.test.js index 7ccce3268..923409144 100644 --- a/package/src/components/Select/v1/Select.test.js +++ b/package/src/components/Select/v1/Select.test.js @@ -55,3 +55,11 @@ test("alphabetize option snapshot", () => { const tree = component.toJSON(); expect(tree).toMatchSnapshot(); }); + +test("when value prop changes to `null`, selection is cleared", () => { + const wrapper = mount(