From 1a26a15bd47345dcbae5d118cea58311a30a2b05 Mon Sep 17 00:00:00 2001 From: Naresh Bhatia Date: Wed, 8 Nov 2017 14:22:46 -0500 Subject: [PATCH] Fixed issue #9027 (#9042) --- src/Form/FormControl.js | 5 ++++- src/Form/FormControl.spec.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Form/FormControl.js b/src/Form/FormControl.js index 3cfd8a45617ceb..7598ae32405ef4 100644 --- a/src/Form/FormControl.js +++ b/src/Form/FormControl.js @@ -178,7 +178,10 @@ class FormControl extends React.Component { }; handleBlur = event => { - if (this.props.onBlur) { + // The event might be undefined. + // For instance, a child component might call this hook + // when an input is disabled but still having the focus. + if (this.props.onBlur && event) { this.props.onBlur(event); } if (this.state.focused) { diff --git a/src/Form/FormControl.spec.js b/src/Form/FormControl.spec.js index 2959ba822b0eda..618ced51c9525d 100644 --- a/src/Form/FormControl.spec.js +++ b/src/Form/FormControl.spec.js @@ -227,7 +227,7 @@ describe('', () => { const handleBlur = spy(); wrapper.setProps({ onBlur: handleBlur }); muiFormControlContext.onFocus(); - muiFormControlContext.onBlur(); + muiFormControlContext.onBlur({}); assert.strictEqual(handleBlur.callCount, 1); }); });