Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 23c20e4

Browse files
committed
Refactoring forceUpdate to prevent it from grabbing development values. Fixes #831
1 parent 76d4270 commit 23c20e4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/components/control-component.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function createControlClass(s = defaultStrategy) {
133133
this.handleFocus = this.createEventHandler('focus').bind(this);
134134
this.handleBlur = this.createEventHandler('blur').bind(this);
135135
this.handleUpdate = this.createEventHandler('change').bind(this);
136+
this.forceHandleUpdate = this.createEventHandler('change', true).bind(this);
136137
this.handleChange = this.handleChange.bind(this);
137138
this.handleLoad = this.handleLoad.bind(this);
138139
this.getMappedProps = this.getMappedProps.bind(this);
@@ -422,11 +423,11 @@ function createControlClass(s = defaultStrategy) {
422423
: value;
423424
}
424425

425-
handleChange(event, forceUpdate = false) {
426+
handleChange(event) {
426427
if (event && event.persist) event.persist();
427428

428429
this.setViewValue(this.getValue(event));
429-
this.handleUpdate(event, forceUpdate);
430+
this.handleUpdate(event);
430431
}
431432

432433
handleKeyPress(event) {
@@ -437,7 +438,7 @@ function createControlClass(s = defaultStrategy) {
437438
if (onKeyPress) onKeyPress(event);
438439

439440
if (event.key === 'Enter') {
440-
this.handleChange(event, true);
441+
this.forceHandleUpdate(event);
441442
}
442443
}
443444

@@ -481,13 +482,13 @@ function createControlClass(s = defaultStrategy) {
481482
if (onLoad) onLoad(modelValue, fieldValue, this.node);
482483
}
483484

484-
createEventHandler(eventName) {
485+
createEventHandler(eventName, forceUpdate = false) {
485486
const eventAction = {
486487
focus: actions.silentFocus,
487488
blur: actions.blur,
488489
}[eventName];
489490

490-
const dispatchBatchActions = (persistedEvent, forceUpdate = false) => {
491+
const dispatchBatchActions = (persistedEvent) => {
491492
const {
492493
dispatch,
493494
model,
@@ -511,7 +512,7 @@ function createControlClass(s = defaultStrategy) {
511512
return persistedEvent;
512513
};
513514

514-
return (event, forceUpdate = false) => {
515+
return (event) => {
515516
const {
516517
controlProps,
517518
parser,
@@ -540,7 +541,7 @@ function createControlClass(s = defaultStrategy) {
540541
}
541542

542543
return compose(
543-
(e) => dispatchBatchActions(e, forceUpdate),
544+
dispatchBatchActions,
544545
parser,
545546
(e) => this.getValue(e),
546547
persistEventWithCallback(controlEventHandler || identity)

0 commit comments

Comments
 (0)