From 2999279ae34ef10c373ca795c87b020ed6753eed Mon Sep 17 00:00:00 2001 From: Leopoldthecoder Date: Tue, 17 Oct 2017 13:43:27 +0800 Subject: [PATCH] minor fixes for select, message-box and textarea --- packages/input/src/calcTextareaHeight.js | 7 +++++-- packages/input/src/input.vue | 8 +++++++- packages/message-box/src/main.vue | 24 ++++++++++++++++++++++-- packages/select/src/select.vue | 6 ++++++ yarn.lock | 10 ++++++---- 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/packages/input/src/calcTextareaHeight.js b/packages/input/src/calcTextareaHeight.js index bf2189d18..18751c630 100644 --- a/packages/input/src/calcTextareaHeight.js +++ b/packages/input/src/calcTextareaHeight.js @@ -52,7 +52,7 @@ function calculateNodeStyling(targetElement) { export default function calcTextareaHeight( targetElement, - minRows = null, + minRows = 1, maxRows = null ) { if (!hiddenTextarea) { @@ -71,6 +71,7 @@ export default function calcTextareaHeight( hiddenTextarea.value = targetElement.value || targetElement.placeholder || ''; let height = hiddenTextarea.scrollHeight; + const result = {}; if (boxSizing === 'border-box') { height = height + borderSize; @@ -87,6 +88,7 @@ export default function calcTextareaHeight( minHeight = minHeight + paddingSize + borderSize; } height = Math.max(minHeight, height); + result.minHeight = `${ minHeight }px`; } if (maxRows !== null) { let maxHeight = singleRowHeight * maxRows; @@ -95,6 +97,7 @@ export default function calcTextareaHeight( } height = Math.min(maxHeight, height); } + result.height = `${ height }px`; - return { height: height + 'px'}; + return result; }; diff --git a/packages/input/src/input.vue b/packages/input/src/input.vue index 88f01e806..b441e577a 100644 --- a/packages/input/src/input.vue +++ b/packages/input/src/input.vue @@ -141,7 +141,13 @@ resizeTextarea() { if (this.$isServer) return; var { autosize, type } = this; - if (!autosize || type !== 'textarea') return; + if (type !== 'textarea') return; + if (!autosize) { + this.textareaCalcStyle = { + minHeight: calcTextareaHeight(this.$refs.textarea).minHeight + }; + return; + } const minRows = autosize.minRows; const maxRows = autosize.maxRows; diff --git a/packages/message-box/src/main.vue b/packages/message-box/src/main.vue index f28e81459..0a285bfd3 100644 --- a/packages/message-box/src/main.vue +++ b/packages/message-box/src/main.vue @@ -15,7 +15,14 @@

{{ message }}

- +
{{ editorErrorMessage }}
@@ -97,6 +104,18 @@ }, methods: { + handleComposition(event) { + if (event.type === 'compositionend') { + setTimeout(() => { + this.isOnComposition = false; + }, 100); + } else { + this.isOnComposition = true; + } + }, + handleKeyup() { + !this.isOnComposition && this.handleAction('confirm'); + }, getSafeClose() { const currentId = this.uid; return () => { @@ -234,7 +253,8 @@ confirmButtonDisabled: false, cancelButtonClass: '', editorErrorMessage: null, - callback: null + callback: null, + isOnComposition: false }; } }; diff --git a/packages/select/src/select.vue b/packages/select/src/select.vue index 3373b6d62..a4e363859 100644 --- a/packages/select/src/select.vue +++ b/packages/select/src/select.vue @@ -226,6 +226,12 @@ }, watch: { + disabled() { + this.$nextTick(() => { + this.resetInputHeight(); + }); + }, + placeholder(val) { this.cachedPlaceHolder = this.currentPlaceholder = val; }, diff --git a/yarn.lock b/yarn.lock index c2039f8d7..a40680ba3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -239,9 +239,11 @@ async-each@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" -async-validator@1.6.9: - version "1.6.9" - resolved "https://registry.yarnpkg.com/async-validator/-/async-validator-1.6.9.tgz#a8309daa8b83421cdbd4628e026d6abb25192d34" +async-validator@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/async-validator/-/async-validator-1.8.1.tgz#6665788ca39269af770e5ee02f0e557f2438d2ca" + dependencies: + babel-runtime "6.x" async@1.5.2, async@1.x, async@^1.3.0, async@^1.4.0, async@^1.5.0: version "1.5.2" @@ -696,7 +698,7 @@ babel-register@^6.18.0: mkdirp "^0.5.1" source-map-support "^0.4.2" -babel-runtime@^6.0.0, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.20.0, babel-runtime@^6.9.0: +babel-runtime@6.x, babel-runtime@^6.0.0, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.20.0, babel-runtime@^6.9.0: version "6.20.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.20.0.tgz#87300bdcf4cd770f09bf0048c64204e17806d16f" dependencies: