mirror of
https://github.com/youzan/vant.git
synced 2025-10-16 16:04:04 +00:00
[bugfix] Field: allow negative number when type is number (#889)
This commit is contained in:
@@ -115,7 +115,7 @@ export default create({
|
||||
if (this.type === 'number') {
|
||||
const { keyCode } = event;
|
||||
const allowPoint = this.value.indexOf('.') === -1;
|
||||
const isValidKey = (keyCode >= 48 && keyCode <= 57) || (keyCode === 46 && allowPoint);
|
||||
const isValidKey = (keyCode >= 48 && keyCode <= 57) || (keyCode === 46 && allowPoint) || keyCode === 45;
|
||||
if (!isValidKey) {
|
||||
event.preventDefault();
|
||||
}
|
||||
@@ -129,6 +129,7 @@ export default create({
|
||||
}
|
||||
|
||||
const el = this.$refs.textarea;
|
||||
/* istanbul ignore if */
|
||||
if (!el) {
|
||||
return;
|
||||
}
|
||||
|
@@ -57,12 +57,13 @@ describe('Field', () => {
|
||||
it('create a textarea field', (done) => {
|
||||
wrapper = mount(Field, {
|
||||
propsData: {
|
||||
type: 'textarea'
|
||||
type: 'textarea',
|
||||
autosize: true
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
expect(wrapper.hasClass('van-field--min-height')).to.be.true;
|
||||
expect(wrapper.hasClass('van-field')).to.be.true;
|
||||
done();
|
||||
}, 50);
|
||||
});
|
||||
|
Reference in New Issue
Block a user