Skip to content

Commit

Permalink
fix(segment-picker): fix no hidden animation (didi#646)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
QiuShuiBai authored and dolymood committed Dec 2, 2019
1 parent 9496ddb commit 41e4b1d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/segment-picker/segment-picker.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<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
Expand Down
4 changes: 2 additions & 2 deletions src/components/time-picker/time-picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions test/unit/specs/time-picker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 41e4b1d

Please sign in to comment.