rsuite 4.10.6 → 4.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/rsuite.js +1 -1
- package/dist/rsuite.min.js +3 -3
- package/dist/rsuite.min.js.map +1 -1
- package/es/InputNumber/InputNumber.js +11 -0
- package/lib/InputNumber/InputNumber.js +11 -0
- package/package.json +1 -1
- package/src/InputNumber/InputNumber.tsx +9 -0
- package/src/InputNumber/test/InputNumberSpec.js +25 -0
|
@@ -164,6 +164,17 @@ function (_React$Component) {
|
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
168
|
+
var preValue = prevProps.value;
|
|
169
|
+
var currentValue = this.props.value;
|
|
170
|
+
|
|
171
|
+
if (preValue !== currentValue) {
|
|
172
|
+
this.setState({
|
|
173
|
+
value: currentValue
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
167
178
|
_proto.getValue = function getValue() {
|
|
168
179
|
var value = this.props.value;
|
|
169
180
|
return _isUndefined(value) ? this.state.value : value;
|
|
@@ -189,6 +189,17 @@ function (_React$Component) {
|
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
191
|
|
|
192
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
193
|
+
var preValue = prevProps.value;
|
|
194
|
+
var currentValue = this.props.value;
|
|
195
|
+
|
|
196
|
+
if (preValue !== currentValue) {
|
|
197
|
+
this.setState({
|
|
198
|
+
value: currentValue
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
192
203
|
_proto.getValue = function getValue() {
|
|
193
204
|
var value = this.props.value;
|
|
194
205
|
return (0, _isUndefined2.default)(value) ? this.state.value : value;
|
package/package.json
CHANGED
|
@@ -115,6 +115,15 @@ class InputNumber extends React.Component<InputNumberProps, InputNumberState> {
|
|
|
115
115
|
this.inputWheelListener.off();
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
componentDidUpdate(prevProps: InputNumberProps) {
|
|
119
|
+
const { value: preValue } = prevProps;
|
|
120
|
+
const { value: currentValue } = this.props;
|
|
121
|
+
if (preValue !== currentValue) {
|
|
122
|
+
this.setState({
|
|
123
|
+
value: currentValue
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
118
127
|
|
|
119
128
|
bindInputRef = ref => {
|
|
120
129
|
this.input = ref;
|
|
@@ -149,4 +149,29 @@ describe('InputNumber', () => {
|
|
|
149
149
|
const instance = getDOMNode(<InputNumber classPrefix="custom-prefix" />);
|
|
150
150
|
assert.ok(instance.className.match(/\bcustom-prefix\b/));
|
|
151
151
|
});
|
|
152
|
+
it('should be change correct value when reset value', () => {
|
|
153
|
+
let refValue = 0;
|
|
154
|
+
const Wrapper = React.forwardRef((props, ref) => {
|
|
155
|
+
const [value, setValue] = React.useState(refValue);
|
|
156
|
+
const reset = () => {
|
|
157
|
+
setValue(null);
|
|
158
|
+
};
|
|
159
|
+
refValue = value;
|
|
160
|
+
return (
|
|
161
|
+
<div ref={ref}>
|
|
162
|
+
<InputNumber value={value} onChange={setValue} />
|
|
163
|
+
<button id="reset" onClick={reset}>
|
|
164
|
+
reset
|
|
165
|
+
</button>
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
});
|
|
169
|
+
const instance = getDOMNode(<Wrapper />);
|
|
170
|
+
const resetBtn = instance.querySelector('#reset');
|
|
171
|
+
ReactTestUtils.Simulate.change(instance.querySelector('.rs-input'), { target: { value: 1 } });
|
|
172
|
+
ReactTestUtils.Simulate.click(resetBtn);
|
|
173
|
+
ReactTestUtils.Simulate.change(instance.querySelector('.rs-input'), { target: { value: 1 } });
|
|
174
|
+
|
|
175
|
+
assert.equal(refValue, 1);
|
|
176
|
+
});
|
|
152
177
|
});
|