showSearchSuggestions of the quick lauch will now inherit the setting from the search widget.

This commit is contained in:
Flo2410 2024-01-29 21:27:42 +00:00
parent ed827837aa
commit 454d51808e
No known key found for this signature in database
GPG Key ID: 8ECB00AC5216DC7F
3 changed files with 14 additions and 3 deletions

View File

@ -359,7 +359,7 @@ There are a few optional settings for the Quick Launch feature:
- `searchDescriptions`: which lets you control whether item descriptions are included in searches. This is off by default. When enabled, results that match the item name will be placed above those that only match the description. - `searchDescriptions`: which lets you control whether item descriptions are included in searches. This is off by default. When enabled, results that match the item name will be placed above those that only match the description.
- `hideInternetSearch`: disable automatically including the currently-selected web search (e.g. from the widget) as a Quick Launch option. This is false by default, enabling the feature. - `hideInternetSearch`: disable automatically including the currently-selected web search (e.g. from the widget) as a Quick Launch option. This is false by default, enabling the feature.
- `showSearchSuggestions`: shows search suggestions for the internet search. This is false by default. - `showSearchSuggestions`: shows search suggestions for the internet search. This value will be inherited from the search widget if it is not specified. If it is not specified there either, it will default to false.
- `hideVisitURL`: disable detecting and offering an option to open URLs. This is false by default, enabling the feature. - `hideVisitURL`: disable detecting and offering an option to open URLs. This is false by default, enabling the feature.
```yaml ```yaml

View File

@ -9,6 +9,7 @@ You can add a search bar to your top widget area that can search using Google, D
- search: - search:
provider: google # google, duckduckgo, bing, baidu, brave or custom provider: google # google, duckduckgo, bing, baidu, brave or custom
focus: true # Optional, will set focus to the search bar on page load focus: true # Optional, will set focus to the search bar on page load
showSearchSuggestions: true # Optional, will show search suggestions
target: _blank # One of _self, _blank, _parent or _top target: _blank # One of _self, _blank, _parent or _top
``` ```

View File

@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useEffect, useState, useRef, useCallback, useContext } from "react"; import { useEffect, useState, useRef, useCallback, useContext } from "react";
import classNames from "classnames"; import classNames from "classnames";
import useSWR from "swr";
import ResolvedIcon from "./resolvedicon"; import ResolvedIcon from "./resolvedicon";
@ -15,10 +16,19 @@ export default function QuickLaunch({
searchProvider, searchProvider,
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { data: widgets } = useSWR("/api/widgets");
const searchWidget = Object.values(widgets).find((w) => w.type === "search");
const { settings } = useContext(SettingsContext); const { settings } = useContext(SettingsContext);
const { searchDescriptions, hideVisitURL, showSearchSuggestions } = settings?.quicklaunch const { searchDescriptions, hideVisitURL } = settings?.quicklaunch
? settings.quicklaunch ? settings.quicklaunch
: { searchDescriptions: false, hideVisitURL: false, showSearchSuggestions: false }; : {
searchDescriptions: false,
hideVisitURL: false,
};
const showSearchSuggestions =
settings?.quicklaunch?.showSearchSuggestions ?? searchWidget.options.showSearchSuggestions ?? false;
const searchField = useRef(); const searchField = useRef();