From 2ab42d87929e321b85b5de086613d4a45d797866 Mon Sep 17 00:00:00 2001 From: wangao <1366463855@qq.com> Date: Sat, 15 Aug 2020 20:07:28 +0800 Subject: [PATCH 1/2] fix: synchronize focused email input on blur to avoid check validity when inputting --- packages/react-dom/src/client/ReactDOMInput.js | 2 +- packages/react-dom/src/events/plugins/ChangeEventPlugin.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-dom/src/client/ReactDOMInput.js b/packages/react-dom/src/client/ReactDOMInput.js index e503b75a95469..c780dc76eba31 100644 --- a/packages/react-dom/src/client/ReactDOMInput.js +++ b/packages/react-dom/src/client/ReactDOMInput.js @@ -411,7 +411,7 @@ export function setDefaultValue( ) { if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js - type !== 'number' || + (type !== 'number' && type !== 'email') || node.ownerDocument.activeElement !== node ) { if (value == null) { diff --git a/packages/react-dom/src/events/plugins/ChangeEventPlugin.js b/packages/react-dom/src/events/plugins/ChangeEventPlugin.js index e9308c583a444..6a856785f0c7e 100644 --- a/packages/react-dom/src/events/plugins/ChangeEventPlugin.js +++ b/packages/react-dom/src/events/plugins/ChangeEventPlugin.js @@ -246,7 +246,11 @@ function getTargetInstForInputOrChangeEvent( function handleControlledInputBlur(node: HTMLInputElement) { const state = (node: any)._wrapperState; - if (!state || !state.controlled || node.type !== 'number') { + if ( + !state || + !state.controlled || + (node.type !== 'number' && node.type !== 'email') + ) { return; } From 8c4467f89d12aa08499181bc553af979a2a7850c Mon Sep 17 00:00:00 2001 From: wangao <1366463855@qq.com> Date: Sat, 15 Aug 2020 20:07:28 +0800 Subject: [PATCH 2/2] fix: synchronize focused email input on blur to avoid check validity when inputting --- packages/react-dom/src/client/ReactDOMInput.js | 2 +- .../react-dom/src/events/plugins/ChangeEventPlugin.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/react-dom/src/client/ReactDOMInput.js b/packages/react-dom/src/client/ReactDOMInput.js index e503b75a95469..c780dc76eba31 100644 --- a/packages/react-dom/src/client/ReactDOMInput.js +++ b/packages/react-dom/src/client/ReactDOMInput.js @@ -411,7 +411,7 @@ export function setDefaultValue( ) { if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js - type !== 'number' || + (type !== 'number' && type !== 'email') || node.ownerDocument.activeElement !== node ) { if (value == null) { diff --git a/packages/react-dom/src/events/plugins/ChangeEventPlugin.js b/packages/react-dom/src/events/plugins/ChangeEventPlugin.js index e9308c583a444..c8c5aa30eaf97 100644 --- a/packages/react-dom/src/events/plugins/ChangeEventPlugin.js +++ b/packages/react-dom/src/events/plugins/ChangeEventPlugin.js @@ -246,13 +246,17 @@ function getTargetInstForInputOrChangeEvent( function handleControlledInputBlur(node: HTMLInputElement) { const state = (node: any)._wrapperState; - if (!state || !state.controlled || node.type !== 'number') { + if ( + !state || + !state.controlled || + (node.type !== 'number' && node.type !== 'email') + ) { return; } if (!disableInputAttributeSyncing) { // If controlled, assign the value attribute to the current value on blur - setDefaultValue((node: any), 'number', (node: any).value); + setDefaultValue((node: any), node.type, (node: any).value); } }