Skip to content

Commit dbe78d1

Browse files
javier-godoypaodb
authored andcommitted
refactor: refactor ExtendedDatePicker for vaadin 24/25 compatibility
1 parent 1e48afa commit dbe78d1

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/main/java/com/flowingcode/addons/ycalendar/ExtendedDatePicker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package com.flowingcode.addons.ycalendar;
2121

22+
import com.flowingcode.vaadin.jsonmigration.JsonMigration;
2223
import com.vaadin.flow.component.ClientCallable;
2324
import com.vaadin.flow.component.Tag;
2425
import com.vaadin.flow.component.datepicker.DatePicker;
@@ -88,7 +89,7 @@ private JsonObject fetchStyles(String minStr, String maxStr) {
8889
String key = m.toString();
8990
getStyles(m).ifPresent(styles -> result.put(key, styles));
9091
}
91-
return result;
92+
return JsonMigration.convertToClientCallableResult(result);
9293
}
9394

9495
private Optional<JsonObject> getStyles(YearMonth yearMonth) {

src/main/resources/META-INF/frontend/fc-date-picker/fc-date-picker.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,34 @@ export class FcDatePicker extends DatePicker {
7070
}
7171
}
7272
};
73+
} else {
74+
this.inputElement.addEventListener('focus', ()=>this.__focused=true);
75+
76+
const self=this;
77+
this.addEventListener('opened-changed', ev=>{
78+
if (ev.detail.value && !self._overlayContent._monthScroller.__fcWrapped) {
79+
this._overlayContent._monthScroller.__fcWrapped = true;
80+
const updateElement = self._overlayContent._monthScroller._updateElement;
81+
self._overlayContent._monthScroller._updateElement = (element, index) => {
82+
updateElement(element,index);
83+
if (element instanceof HTMLElement) {
84+
this._updateMonthStyles(element);
85+
}
86+
};
87+
const createElement = self._overlayContent._monthScroller._createElement;
88+
self._overlayContent._monthScroller._createElement = () => {
89+
var calendar = createElement();
90+
setTimeout(()=>this._updateMonthStyles(calendar));
91+
return calendar;
92+
};
93+
}
94+
});
7395
}
7496
}
7597

7698
refreshAll() {
7799
this._styles = {};
78-
const overlayContent = this._overlayContent;
100+
const overlayContent = this._overlayContent || this.querySelector("vaadin-date-picker-overlay-content");
79101
if (overlayContent) {
80102
overlayContent._monthScroller.querySelectorAll("vaadin-month-calendar").forEach(calendar=>this._updateMonthStyles(calendar));
81103
}

0 commit comments

Comments
 (0)