mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
fix(filter): ensure proper initialization of filter components
- Add null check and default return value in getFilterState method - Call onload() in modal and popover to ensure component initialization - Prevents potential runtime errors when filter state is not initialized
This commit is contained in:
parent
2b1018ec46
commit
78cdf77c1f
3 changed files with 10 additions and 2 deletions
|
|
@ -1079,6 +1079,13 @@ export class TaskFilterComponent extends Component {
|
|||
|
||||
// Public method to get current filter state
|
||||
public getFilterState(): RootFilterState {
|
||||
// Handle case where rootFilterState might not be initialized
|
||||
if (!this.rootFilterState) {
|
||||
return {
|
||||
rootCondition: "any",
|
||||
filterGroups: [],
|
||||
};
|
||||
}
|
||||
return JSON.parse(JSON.stringify(this.rootFilterState));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ export class ViewTaskFilterModal extends Modal {
|
|||
this.leafId,
|
||||
this.plugin
|
||||
);
|
||||
// Ensure the component is properly loaded
|
||||
this.taskFilterComponent.onload();
|
||||
}
|
||||
|
||||
onClose() {
|
||||
|
|
|
|||
|
|
@ -53,8 +53,7 @@ export class ViewTaskFilterPopover
|
|||
this.leafId,
|
||||
this.plugin
|
||||
);
|
||||
|
||||
// Initialize editor and display task
|
||||
// Ensure the component is properly loaded
|
||||
this.taskFilterComponent.onload();
|
||||
|
||||
// Create the popover
|
||||
|
|
|
|||
Loading…
Reference in a new issue