From 87d7c4dac20ad46f705495f7ddb8aab28cdafd7f Mon Sep 17 00:00:00 2001 From: pjanik Date: Thu, 22 Aug 2024 20:37:37 +0200 Subject: [PATCH] fix: fix month highlighting in the day slider [PT-188059193] --- .../components/slider/infinite-day-slider.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/grasp-seasons/components/slider/infinite-day-slider.tsx b/src/grasp-seasons/components/slider/infinite-day-slider.tsx index 3852f81..7af282e 100644 --- a/src/grasp-seasons/components/slider/infinite-day-slider.tsx +++ b/src/grasp-seasons/components/slider/infinite-day-slider.tsx @@ -33,12 +33,11 @@ export default class InfiniteDaySlider extends Slider { this.generateMonthTicks(nextProps.lang); } const options = this.getSliderOpts(nextProps); - const originalSlide = options.slide; - - options.slide = (event: any, ui: any) => { - originalSlide(event, ui); - const value = ui.value; - const month = Math.floor(value / MONTH_LEN); + const value = options.value; + if (value !== undefined) { + const date = new Date(2024, 0); + date.setDate(value + 1); + const month = date.getMonth(); this.$slider.find(".ui-slider-tick-label").each(function(this: any, idx: number) { const $label = $(this); if (idx === month) { @@ -47,7 +46,7 @@ export default class InfiniteDaySlider extends Slider { $label.removeClass("active"); } }); - }; + } this.$slider[this.sliderFuncName](options); }