[UI] Add search result preview (#12475)

* [UI] Add search result preview

* Updated search docs
This commit is contained in:
Oliver
2026-07-27 16:02:33 +10:00
committed by GitHub
parent 35f2f1aab6
commit eb5138127b
5 changed files with 33 additions and 0 deletions
@@ -159,6 +159,14 @@ USER_SETTINGS: dict[str, InvenTreeSettingsKeyType] = {
'default': 10,
'validator': [int, MinValueValidator(1)],
},
'SEARCH_RESULTS_PREVIEW_PANEL': {
'name': _('Search Results Preview Panel'),
'description': _(
'Open search results in the preview panel, rather than navigating directly to the result'
),
'default': False,
'validator': bool,
},
'SEARCH_REGEX': {
'name': _('Regex Search'),
'description': _('Enable regular expressions in search queries'),
@@ -47,6 +47,7 @@ import {
} from '@lib/functions/Navigation';
import { showNotification } from '@mantine/notifications';
import { api } from '../../App';
import { openGlobalPreview } from '../../states/PreviewDrawerState';
import { useUserSettingsState } from '../../states/SettingsStates';
import { useUserState } from '../../states/UserState';
import { RenderInstance } from '../render/Instance';
@@ -468,6 +469,17 @@ export function SearchDrawer({
return;
}
const showPreviewPanel =
userSettings.isSet('ENABLE_PREVIEW_PANEL') &&
userSettings.isSet('SEARCH_RESULTS_PREVIEW_PANEL');
if (showPreviewPanel && !eventModified(event)) {
// Open the result in the preview panel, keeping the search drawer open
cancelEvent(event);
openGlobalPreview(query, pk);
return;
}
if (eventModified(event)) {
// Keep the drawer open in this condition
} else {
@@ -80,6 +80,7 @@ export default function UserSettings() {
'SEARCH_WHOLE',
'SEARCH_REGEX',
'SEARCH_NOTES',
'SEARCH_RESULTS_PREVIEW_PANEL',
'SEARCH_PREVIEW_RESULTS',
'SEARCH_PREVIEW_SHOW_PARTS',
'SEARCH_HIDE_INACTIVE_PARTS',