Commit 5f181c31 authored by Sean's avatar Sean Committed by Jiewei Qian

date-picker: fix week highlight on year boundary (#13883)

When the selected week spans across two years (e.g. 2018-12-30 2019-01-05),
they should be highlighted in both month tables.
parent 9579d00b
......@@ -32,7 +32,7 @@
</template>
<script>
import { getFirstDayOfMonth, getDayCountOfMonth, getWeekNumber, getStartDateOfMonth, nextDate, isDate, clearTime as _clearTime} from '../util';
import { getFirstDayOfMonth, getDayCountOfMonth, getWeekNumber, getStartDateOfMonth, prevDate, nextDate, isDate, clearTime as _clearTime} from '../util';
import Locale from 'element-ui/src/mixins/locale';
import { arrayFindIndex, arrayFind, coerceTruthyValueToArray } from 'element-ui/src/utils/util';
......@@ -321,8 +321,12 @@
newDate.setDate(parseInt(cell.text, 10));
const valueYear = isDate(this.value) ? this.value.getFullYear() : null;
return year === valueYear && getWeekNumber(newDate) === getWeekNumber(this.value);
if (isDate(this.value)) {
const dayOffset = (this.value.getDay() - this.firstDayOfWeek + 7) % 7 - 1;
const weekDate = prevDate(this.value, dayOffset);
return weekDate.getTime() === newDate.getTime();
}
return false;
},
markRange(minDate, maxDate) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment