diff --git a/src/components/input/input.vue b/src/components/input/input.vue
index da7135bf..2d8498c9 100644
--- a/src/components/input/input.vue
+++ b/src/components/input/input.vue
@@ -2,7 +2,7 @@
-
+
@@ -204,7 +204,8 @@
slotReady: false,
textareaStyles: {},
isOnComposition: false,
- showPassword: false
+ showPassword: false,
+ clearableIconOffset: 0
};
},
computed: {
@@ -279,6 +280,12 @@
}
return (this.value || '').length;
+ },
+ clearableStyles () {
+ const style = {};
+ let offset = this.clearableIconOffset;
+ if (offset) style.transform = `translateX(-${offset}px)`;
+ return style;
}
},
methods: {
@@ -396,16 +403,31 @@
setTimeout(() => {
this.$refs.input.setSelectionRange(len, len);
}, 0);
+ },
+ handleCalcIconOffset () {
+ const $el = this.$el.querySelectorAll('.ivu-input-group-append')[0];
+ if ($el) {
+ this.clearableIconOffset = $el.offsetWidth;
+ } else {
+ this.clearableIconOffset = 0;
+ }
}
},
watch: {
value (val) {
this.setCurrentValue(val);
+ },
+ type () {
+ this.$nextTick(this.handleCalcIconOffset);
}
},
mounted () {
this.slotReady = true;
this.resizeTextarea();
+ this.handleCalcIconOffset();
+ },
+ updated () {
+ this.$nextTick(this.handleCalcIconOffset);
}
};