Skip to content

Commit

Permalink
fix: fix composition input in $memo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqiboy committed Nov 24, 2020
1 parent 11a9087 commit 08a949a
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 41 deletions.
19 changes: 12 additions & 7 deletions dist/react-antd-formutil.cjs.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,13 @@ var FormItem = /*#__PURE__*/function (_Component) {
} // If $memo is true, pass the children to Field for SCU diffing.


if (props.$memo === true) {
fieldProps.__DIFF__ = childList;
if (fieldProps.$memo === true) {
fieldProps.__DIFF__ = {
childList: childList,
compositionValue: this.compositionValue
};
} else if (Array.isArray(fieldProps.$memo)) {
fieldProps.$memo = fieldProps.$memo.concat(this.compositionValue);
}

var children = typeof childList === 'function' ? childList : React.Children.only(childList);
Expand Down Expand Up @@ -551,16 +556,16 @@ var FormItem = /*#__PURE__*/function (_Component) {
default:
childProps = (_childProps = {
onCompositionEnd: function onCompositionEnd(ev) {
_this2.isComposition = false;
_this2.isComposing = false;
delete _this2.compositionValue;

_onChange(ev);
},
onCompositionStart: function onCompositionStart() {
return _this2.isComposition = true;
return _this2.isComposing = true;
}
}, defineProperty(_childProps, changePropName, function (ev) {
if (_this2.isComposition) {
if (_this2.isComposing) {
var _ev$target$valuePropN, _ev$target;

_this2.compositionValue = (_ev$target$valuePropN = (_ev$target = ev.target) === null || _ev$target === void 0 ? void 0 : _ev$target[valuePropName]) !== null && _ev$target$valuePropN !== void 0 ? _ev$target$valuePropN : ev;
Expand All @@ -574,8 +579,8 @@ var FormItem = /*#__PURE__*/function (_Component) {
_onChange.apply(void 0, [ev].concat(rest));
}
}), defineProperty(_childProps, valuePropName, 'compositionValue' in _this2 ? _this2.compositionValue : value), defineProperty(_childProps, blurPropName, function () {
if (_this2.isComposition) {
_this2.isComposition = false;
if (_this2.isComposing) {
_this2.isComposing = false;
delete _this2.compositionValue;

_onChange.apply(void 0, arguments);
Expand Down
2 changes: 1 addition & 1 deletion dist/react-antd-formutil.cjs.production.js

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions dist/react-antd-formutil.esm.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,13 @@ var FormItem = /*#__PURE__*/function (_Component) {
} // If $memo is true, pass the children to Field for SCU diffing.


if (props.$memo === true) {
fieldProps.__DIFF__ = childList;
if (fieldProps.$memo === true) {
fieldProps.__DIFF__ = {
childList: childList,
compositionValue: this.compositionValue
};
} else if (Array.isArray(fieldProps.$memo)) {
fieldProps.$memo = fieldProps.$memo.concat(this.compositionValue);
}

var children = typeof childList === 'function' ? childList : Children.only(childList);
Expand Down Expand Up @@ -501,16 +506,16 @@ var FormItem = /*#__PURE__*/function (_Component) {
default:
childProps = (_childProps = {
onCompositionEnd: function onCompositionEnd(ev) {
_this2.isComposition = false;
_this2.isComposing = false;
delete _this2.compositionValue;

_onChange(ev);
},
onCompositionStart: function onCompositionStart() {
return _this2.isComposition = true;
return _this2.isComposing = true;
}
}, _defineProperty(_childProps, changePropName, function (ev) {
if (_this2.isComposition) {
if (_this2.isComposing) {
var _ev$target$valuePropN, _ev$target;

_this2.compositionValue = (_ev$target$valuePropN = (_ev$target = ev.target) === null || _ev$target === void 0 ? void 0 : _ev$target[valuePropName]) !== null && _ev$target$valuePropN !== void 0 ? _ev$target$valuePropN : ev;
Expand All @@ -524,8 +529,8 @@ var FormItem = /*#__PURE__*/function (_Component) {
_onChange.apply(void 0, [ev].concat(rest));
}
}), _defineProperty(_childProps, valuePropName, 'compositionValue' in _this2 ? _this2.compositionValue : value), _defineProperty(_childProps, blurPropName, function () {
if (_this2.isComposition) {
_this2.isComposition = false;
if (_this2.isComposing) {
_this2.isComposing = false;
delete _this2.compositionValue;

_onChange.apply(void 0, arguments);
Expand Down
2 changes: 1 addition & 1 deletion dist/react-antd-formutil.esm.production.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 08a949a

Please sign in to comment.