Current Behavior
Admin settings search crashes with:
TypeError: e.tree.map is not a function
The error occurs in GeneralSearchSource.tsx when rendering search results for settings that use the tree property (e.g. extensions using generalIndexItems with tree).
Steps to Reproduce
- Open the Flarum admin panel.
- Open the search modal (e.g. via the search icon or keyboard shortcut).
- Search for a term that matches an extension setting (e.g. "upload", "file", "mime").
- The error appears and the search modal fails to render results.
Expected Behavior
Search results should render without errors, with breadcrumb paths (e.g. "Preferences › Max file size") when settings define a tree property.
Screenshots
No response
Environment
Output of php flarum info
Output of "php flarum info", run this in terminal in your Flarum directory.
Possible Solution
In framework/core/js/src/admin/components/GeneralSearchSource.tsx around line 130, the code is:
'tree' in setting && setting.tree ? setting.tree.map(extractText).push(label) : [label],
Array.prototype.push() returns the new length (a number), so the tree argument passed to GeneralSearchResult is a number instead of an array. Later, result.tree.map() fails because numbers don’t have .map.
Fix: use an expression that returns an array, for example:
'tree' in setting && setting.tree ? [...setting.tree.map(extractText), label] : [label],
Additional Context
The bug affects any extension that registers settings via generalIndexItems('settings', ...) with a tree property. For example, fof/upload uses tree: [t('fof-upload.admin.labels.preferences.title')] for its settings. A temporary workaround is to remove the tree property from those items so the fallback [label] is used, but that removes breadcrumb paths in search results.
Current Behavior
Admin settings search crashes with:
The error occurs in GeneralSearchSource.tsx when rendering search results for settings that use the tree property (e.g. extensions using generalIndexItems with tree).
Steps to Reproduce
Expected Behavior
Search results should render without errors, with breadcrumb paths (e.g. "Preferences › Max file size") when settings define a tree property.
Screenshots
No response
Environment
Output of
php flarum infoPossible Solution
In framework/core/js/src/admin/components/GeneralSearchSource.tsx around line 130, the code is:
Array.prototype.push() returns the new length (a number), so the tree argument passed to GeneralSearchResult is a number instead of an array. Later, result.tree.map() fails because numbers don’t have .map.
Fix: use an expression that returns an array, for example:
Additional Context
The bug affects any extension that registers settings via generalIndexItems('settings', ...) with a tree property. For example, fof/upload uses tree: [t('fof-upload.admin.labels.preferences.title')] for its settings. A temporary workaround is to remove the tree property from those items so the fallback [label] is used, but that removes breadcrumb paths in search results.