From a19beced128918c308a26b655daf82d9622c398a Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Fri, 31 Jul 2020 15:05:58 +0800 Subject: [PATCH] fix: input-number uphandle cannot click --- antdv-demo | 2 +- components/input-number/index.jsx | 9 ++++++ components/vc-input-number/src/index.js | 43 ++++++++++++------------- examples/App.vue | 2 +- package.json | 4 +-- 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/antdv-demo b/antdv-demo index e58ddcdb3..bda092900 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit e58ddcdb3436fbf430e69953053d73114ce6ce6b +Subproject commit bda092900405709ab19219754c43d68975a143be diff --git a/components/input-number/index.jsx b/components/input-number/index.jsx index d463576c9..6b82355d1 100644 --- a/components/input-number/index.jsx +++ b/components/input-number/index.jsx @@ -38,6 +38,15 @@ const InputNumber = { configProvider: inject('configProvider', ConfigConsumerProps), }; }, + mounted() { + this.$nextTick(() => { + if (process.env.NODE_ENV === 'test') { + if (this.autofocus && !this.disabled) { + this.focus(); + } + } + }); + }, methods: { saveInputNumber(inputNumberRef) { this.inputNumberRef = inputNumberRef; diff --git a/components/vc-input-number/src/index.js b/components/vc-input-number/src/index.js index 283725b91..b57930d62 100755 --- a/components/vc-input-number/src/index.js +++ b/components/vc-input-number/src/index.js @@ -6,8 +6,6 @@ import classNames from 'classnames'; import KeyCode from '../../_util/KeyCode'; import InputHandler from './InputHandler'; -function noop() {} - function preventDefault(e) { e.preventDefault(); } @@ -77,6 +75,7 @@ const inputNumberProps = { name: PropTypes.string, id: PropTypes.string, type: PropTypes.string, + maxlength: PropTypes.any, }; export default { @@ -115,9 +114,6 @@ export default { }, mounted() { this.$nextTick(() => { - if (this.autofocus && !this.disabled) { - this.focus(); - } this.updatedFunc(); }); }, @@ -691,21 +687,21 @@ export default { let downEvents; if (useTouch) { upEvents = { - onTouchstart: editable && !upDisabledClass ? this.up : noop, + onTouchstart: editable && !upDisabledClass && this.up, onTouchend: this.stop, }; downEvents = { - onTouchstart: editable && !downDisabledClass ? this.down : noop, + onTouchstart: editable && !downDisabledClass && this.down, onTouchend: this.stop, }; } else { upEvents = { - onMousedown: editable && !upDisabledClass ? this.up : noop, + onMousedown: editable && !upDisabledClass && this.up, onMouseup: this.stop, onMouseleave: this.stop, }; downEvents = { - onMousedown: editable && !downDisabledClass ? this.down : noop, + onMousedown: editable && !downDisabledClass && this.down, onMouseup: this.stop, onMouseleave: this.stop, }; @@ -735,7 +731,6 @@ export default { ...downEvents, ref: this.saveDown, }; - return (