obsidian-text-expand
obsidian-text-expand copied to clipboard
Results Not Rendered. Error: Cannot Read Properties of Undefined (reading 'view')
Context
I've been very happy with Text Expand until recently. In the last weeks the plugin began erroring out while trying to render search results.
I know I'm using the same view template I've used for months, because my obsidian "daily note template" includes the same text expand query and template. Notes generated from this template several months ago are just as affected as the note generated today.
The error message reported by the developer console is:

Using the query shown here:

While the example New Note for 2023-04-14 shows up in the search results to the left, it is not included in the expander output.

Debugging this on my own...

Evaluating this line in the console yields and empty array:

Okay, the problem is that the view is displaying more than one child in the left split.
I've tested and validated this as a solution by editing the local copy of main.js.
getLeftSplitElementOfViewStateType(viewStateType) {
// @ts-ignore
for (const child of this.app.workspace.leftSplit.children) {
const filterForSearchResult = child.children.filter(e => e.getViewState().type === viewStateType);
if (filterForSearchResult === undefined || filterForSearchResult.length < 1) {
continue;
}
return filterForSearchResult[0];
}
return undefined;
}
getSearchView() {
const searchElement = this.getLeftSplitElementOfViewStateType('search');
if (undefined == searchElement) {
return undefined;
}
const view = searchElement.view;
if ('searchComponent' in view) {
return view;
}
return undefined;
}
I've used my very limited TS skills to converted the above into TS, and created PR #84 to resolve this issue.