mirror of https://github.com/ElemeFE/element
ColorPicker: not trigger form validation when dragging (#13299)
* ColorPicker: not trigger form validation when dragging * update test case for inputpull/13311/head
parent
9d09d0dbf4
commit
9a31f5f6e6
|
@ -666,6 +666,7 @@ Search data from server-side.
|
||||||
|form | same as `form` in native input | string | — | — |
|
|form | same as `form` in native input | string | — | — |
|
||||||
| label | label text | string | — | — |
|
| label | label text | string | — | — |
|
||||||
| tabindex | input tabindex | string | - | - |
|
| tabindex | input tabindex | string | - | - |
|
||||||
|
| validate-event | whether to trigger form validation | boolean | - | - |
|
||||||
|
|
||||||
### Input slots
|
### Input slots
|
||||||
|
|
||||||
|
|
|
@ -704,6 +704,7 @@ Búsqueda de datos desde el servidor.
|
||||||
| suffix-icon | suffix icon class | string | — | — |
|
| suffix-icon | suffix icon class | string | — | — |
|
||||||
| hide-loading | si se debe ocultar el icono de loading en la búsqueda remota | boolean | — | false |
|
| hide-loading | si se debe ocultar el icono de loading en la búsqueda remota | boolean | — | false |
|
||||||
| popper-append-to-body | si añadir el desplegable al cuerpo. Si la posición del menú desplegable es incorrecta, puede intentar establecer este prop a false | boolean | - | true |
|
| popper-append-to-body | si añadir el desplegable al cuerpo. Si la posición del menú desplegable es incorrecta, puede intentar establecer este prop a false | boolean | - | true |
|
||||||
|
| validate-event | whether to trigger form validation | boolean | - | - |
|
||||||
|
|
||||||
### Autocomplete Slots
|
### Autocomplete Slots
|
||||||
|
|
||||||
|
|
|
@ -822,6 +822,7 @@ export default {
|
||||||
| form | 原生属性 | string | — | — |
|
| form | 原生属性 | string | — | — |
|
||||||
| label | 输入框关联的label文字 | string | — | — |
|
| label | 输入框关联的label文字 | string | — | — |
|
||||||
| tabindex | 输入框的tabindex | string | - | - |
|
| tabindex | 输入框的tabindex | string | - | - |
|
||||||
|
| validate-event | 输入时是否触发表单的校验 | boolean | - | - |
|
||||||
|
|
||||||
### Input Slots
|
### Input Slots
|
||||||
| name | 说明 |
|
| name | 说明 |
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
v-model="customInput"
|
v-model="customInput"
|
||||||
@keyup.native.enter="handleConfirm"
|
@keyup.native.enter="handleConfirm"
|
||||||
@blur="handleConfirm"
|
@blur="handleConfirm"
|
||||||
|
:validate-event="false"
|
||||||
size="mini">
|
size="mini">
|
||||||
</el-input>
|
</el-input>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -34,10 +34,13 @@
|
||||||
import Color from './color';
|
import Color from './color';
|
||||||
import PickerDropdown from './components/picker-dropdown.vue';
|
import PickerDropdown from './components/picker-dropdown.vue';
|
||||||
import Clickoutside from 'element-ui/src/utils/clickoutside';
|
import Clickoutside from 'element-ui/src/utils/clickoutside';
|
||||||
|
import Emitter from 'element-ui/src/mixins/emitter';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ElColorPicker',
|
name: 'ElColorPicker',
|
||||||
|
|
||||||
|
mixins: [Emitter],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
value: String,
|
value: String,
|
||||||
showAlpha: Boolean,
|
showAlpha: Boolean,
|
||||||
|
@ -115,14 +118,19 @@
|
||||||
if (this.colorDisabled) return;
|
if (this.colorDisabled) return;
|
||||||
this.showPicker = !this.showPicker;
|
this.showPicker = !this.showPicker;
|
||||||
},
|
},
|
||||||
confirmValue(value) {
|
confirmValue() {
|
||||||
this.$emit('input', this.color.value);
|
const value = this.color.value;
|
||||||
this.$emit('change', this.color.value);
|
this.$emit('input', value);
|
||||||
|
this.$emit('change', value);
|
||||||
|
this.dispatch('ElFormItem', 'el.form.change', value);
|
||||||
this.showPicker = false;
|
this.showPicker = false;
|
||||||
},
|
},
|
||||||
clearValue() {
|
clearValue() {
|
||||||
this.$emit('input', null);
|
this.$emit('input', null);
|
||||||
this.$emit('change', null);
|
this.$emit('change', null);
|
||||||
|
if (this.value !== null) {
|
||||||
|
this.dispatch('ElFormItem', 'el.form.change', null);
|
||||||
|
}
|
||||||
this.showPanelColor = false;
|
this.showPanelColor = false;
|
||||||
this.showPicker = false;
|
this.showPicker = false;
|
||||||
this.resetColor();
|
this.resetColor();
|
||||||
|
|
|
@ -207,6 +207,42 @@ describe('Input', () => {
|
||||||
}, 20);
|
}, 20);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('validateEvent', done => {
|
||||||
|
const spy = sinon.spy();
|
||||||
|
vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-form :model="model" :rules="rules">
|
||||||
|
<el-form-item prop="input">
|
||||||
|
<el-input v-model="model.input" :validate-event="false">
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
`,
|
||||||
|
data() {
|
||||||
|
const validator = (rule, value, callback) => {
|
||||||
|
spy();
|
||||||
|
callback();
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
model: {
|
||||||
|
input: ''
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
input: [
|
||||||
|
{ validator }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
vm.model.input = '123';
|
||||||
|
vm.$nextTick(() => {
|
||||||
|
expect(spy.called).to.be.false;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Input Events', () => {
|
describe('Input Events', () => {
|
||||||
it('event:focus & blur', done => {
|
it('event:focus & blur', done => {
|
||||||
vm = createVue({
|
vm = createVue({
|
||||||
|
|
|
@ -78,6 +78,9 @@ export declare class ElInput extends ElementUIComponent {
|
||||||
/** Same as form in native input */
|
/** Same as form in native input */
|
||||||
form: string
|
form: string
|
||||||
|
|
||||||
|
/** Whether to trigger form validatio */
|
||||||
|
validateEvent: boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Focus the Input component
|
* Focus the Input component
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue