From d0e27b65b5f8138d85be1d9298fbabe9047a474c Mon Sep 17 00:00:00 2001 From: Luis Rudge Date: Thu, 12 Jan 2017 17:41:37 -0300 Subject: [PATCH] clearning fields when lock closes. fix #795 --- src/core/actions.js | 6 ++++-- src/field/index.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/actions.js b/src/core/actions.js index bfb41e594..7445551ab 100644 --- a/src/core/actions.js +++ b/src/core/actions.js @@ -5,7 +5,7 @@ import { syncRemoteData } from './remote_data'; import * as l from './index'; import { img as preload } from '../utils/preload_utils'; import { defaultProps } from '../ui/box/container'; -import { isFieldValid, showInvalidField, hideInvalidFields } from '../field/index'; +import { isFieldValid, showInvalidField, hideInvalidFields, clearFields } from '../field/index'; export function setupLock(id, clientID, domain, options, hookRunner, emitEventFn) { let m = l.setup(id, clientID, domain, options, hookRunner, emitEventFn); @@ -104,11 +104,12 @@ export function closeLock(id, force = false, callback = () => {}) { // otherwise just reset. if (l.ui.appendContainer(m)) { swap(updateEntity, "lock", id, l.stopRendering); - + setTimeout(() => { swap(updateEntity, "lock", id, (m) => { m = hideInvalidFields(m); m = l.reset(m); + m = clearFields(m); return m; }); m = read(getEntity, "lock", id); @@ -118,6 +119,7 @@ export function closeLock(id, force = false, callback = () => {}) { swap(updateEntity, "lock", id, (m) => { m = hideInvalidFields(m); m = l.reset(m); + m = clearFields(m); return m; }); callback(m); diff --git a/src/field/index.js b/src/field/index.js index 65be4e8ec..19743bb7d 100644 --- a/src/field/index.js +++ b/src/field/index.js @@ -99,11 +99,11 @@ export function clearFields(m, fields) { let keyPaths; if (!fields || fields.length === 0) { - keyPaths = ["field"]; + keyPaths = [["field"]]; } else { keyPaths = fields.map(x => ["field", x]); } - + return keyPaths.reduce((r, v) => r.removeIn(v), m); }