mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-22 22:49:15 +08:00
fix(DateTimePicker): fix action when max-hour or max-minute is set smaller then current time(#5005) (#5006)
This commit is contained in:
parent
7aee4fb9a2
commit
4c9eb995d4
@ -74,9 +74,9 @@ export default createComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
updateInnerValue() {
|
updateInnerValue() {
|
||||||
const indexes = this.$refs.picker.getIndexes();
|
const [hourIndex, minuteIndex] = this.$refs.picker.getIndexes();
|
||||||
const hour = this.originColumns[0].values[indexes[0]];
|
const hour = this.originColumns[0].values[hourIndex] || this.originColumns[0].values[0];
|
||||||
const minute = this.originColumns[1].values[indexes[1]];
|
const minute = this.originColumns[1].values[minuteIndex] || this.originColumns[1].values[0];
|
||||||
const value = `${hour}:${minute}`;
|
const value = `${hour}:${minute}`;
|
||||||
|
|
||||||
this.innerValue = this.formatValue(value);
|
this.innerValue = this.formatValue(value);
|
||||||
|
@ -107,3 +107,19 @@ test('change min-minute and emit correct value', async () => {
|
|||||||
wrapper.find('.van-picker__confirm').trigger('click');
|
wrapper.find('.van-picker__confirm').trigger('click');
|
||||||
expect(wrapper.emitted('confirm')[0][0]).toEqual('12:30');
|
expect(wrapper.emitted('confirm')[0][0]).toEqual('12:30');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('set max-hour & max-minute smaller than current then emit correct value', async () => {
|
||||||
|
const wrapper = mount(TimePicker, {
|
||||||
|
propsData: {
|
||||||
|
value: '23:59',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await later();
|
||||||
|
wrapper.setProps({
|
||||||
|
maxHour: 2,
|
||||||
|
maxMinute: 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
wrapper.find('.van-picker__confirm').trigger('click');
|
||||||
|
expect(wrapper.emitted('confirm')[0][0]).toEqual('00:00');
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user