提交 41e4b1d5 编写于 作者: Q QiuShuiBai 提交者: doly mood

fix(segment-picker): fix no hidden animation (#646)

* fix(segment-picker): fix no hidden animation

* fix(time-picker): value last choose was changed when open again

* test(time-picker): add the value of the selected test
上级 9496ddb3
<template>
<div class="cube-segment-picker" v-show="isVisible">
<div class="cube-segment-picker">
<!-- Direct props will recover the property from v-bind Object expect 'is'. -->
<!-- To ensure the priority of v-bind Object which is from user configure, we check the property of item in every prop. -->
<component
......
......@@ -258,8 +258,8 @@
_updateSelectedIndex() {
const value = this.value
const minTime = this.minTime
if (value <= +minTime) {
// fix the value last choose was changed when time-picker is opened again
if (value < Math.floor(minTime / MINUTE_TIMESTAMP) * MINUTE_TIMESTAMP) {
this.selectedIndex = [0, 0, 0]
} else {
// calculate dayIndex
......
......@@ -235,6 +235,36 @@ describe('TimePicker', () => {
console.warn = originWarn
})
it('should show the value last choose when time-picker is opened again', function (done) {
const selectHandle = sinon.spy()
vm = createPicker({
}, {
select: selectHandle
})
new Promise((resolve) => {
vm.show()
vm.selectedIndex = [0, 1, 0]
setTimeout(() => {
let confirmBtn = vm.$el.querySelector('.cube-picker-confirm')
confirmBtn.click()
let value = selectHandle.lastCall.args[0]
setTimeout(() => {
resolve(value)
})
}, 100)
}).then((firstValue) => {
vm.show()
setTimeout(() => {
let confirmBtn = vm.$el.querySelector('.cube-picker-confirm')
confirmBtn.click()
let value = selectHandle.lastCall.args[0]
expect(firstValue)
.to.be.equal(value)
done()
}, 100)
})
})
testMinuteStep()
testMin()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册