mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Calendar): incorrect month title after auto scroll (#5569)
This commit is contained in:
parent
25574aab72
commit
2047db68d9
@ -80,6 +80,10 @@ export default createComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
scrollIntoView() {
|
||||
this.$refs.days.scrollIntoView();
|
||||
},
|
||||
|
||||
getDayType(day) {
|
||||
const { type, minDate, maxDate, currentDate } = this;
|
||||
|
||||
@ -166,12 +170,14 @@ export default createComponent({
|
||||
genDays() {
|
||||
if (this.visible) {
|
||||
return (
|
||||
<div class={bem('days')}>
|
||||
<div ref="days" class={bem('days')}>
|
||||
{this.genMark()}
|
||||
{this.days.map(this.genDay)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <div ref="days" />;
|
||||
},
|
||||
|
||||
genDay(item, index) {
|
||||
|
@ -158,7 +158,7 @@ export default createComponent({
|
||||
|
||||
this.months.some((month, index) => {
|
||||
if (compareMonth(month, targetDate) === 0) {
|
||||
this.$refs.months[index].$el.scrollIntoView();
|
||||
this.$refs.months[index].scrollIntoView();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ test('should scroll to current month when show', async done => {
|
||||
});
|
||||
|
||||
Element.prototype.scrollIntoView = function() {
|
||||
expect(this).toEqual(wrapper.findAll('.van-calendar__month').at(3).element);
|
||||
expect(this.parentNode).toEqual(wrapper.findAll('.van-calendar__month').at(3).element);
|
||||
done();
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user