Skip to content

Commit efa1827

Browse files
committed
SVY-21198 Incident | TypeError: Cannot read properties of undefined
(reading 'querySelector') [ai]
1 parent fd71419 commit efa1827

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

projects/bootstrapcomponents/src/calendar/basecalendar.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,25 @@ export class ServoyBootstrapBaseCalendar extends ServoyBootstrapBasefield<HTMLDi
118118
initializePicker() {
119119
if (!this.picker) {
120120
this.picker = new TempusDominus(this.getNativeElement(), this.config);
121+
this.patchHandleFocus();
121122
this.picker.subscribe(Namespace.events.change, (event) => this.dateChanged(event));
122123
}
123124
}
124125

126+
protected patchHandleFocus() {
127+
const display = (this.picker as any).display;
128+
if (!display || typeof display._handleFocus !== 'function') return;
129+
const original = display._handleFocus.bind(display);
130+
display._handleFocus = () => {
131+
if (!display.widget) return;
132+
try {
133+
original();
134+
} catch (e) {
135+
this.log.warn('Tempus Dominus focus error suppressed:', e);
136+
}
137+
};
138+
}
139+
125140
public updateConfig(format: string) {
126141
const showYear = format.indexOf('y') >= 0;
127142
const showMonth = format.indexOf('M') >= 0;

projects/bootstrapcomponents/src/calendar/calendar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ export class ServoyBootstrapCalendar extends ServoyBootstrapBaseCalendar {
160160
(this.inputElementRef.nativeElement as HTMLInputElement).value='';
161161
this.picker = new TempusDominus(this.getNativeElement(), this.config);
162162
(this.inputElementRef.nativeElement as HTMLInputElement).value = currentValue;
163+
this.patchHandleFocus();
163164
this.picker.dates.formatInput = (date: DateTime) => date?this.formattingService.format(date, this.format, false):'';
164165
this.picker.dates.parseInput = (value: string) => {
165166
const parsed = this.formattingService.parse(value?value.trim():null, this.format, true, this.dataProviderID, true);

0 commit comments

Comments
 (0)