diff --git a/docs/configs/settings.md b/docs/configs/settings.md index de0ab879..d3e9a837 100644 --- a/docs/configs/settings.md +++ b/docs/configs/settings.md @@ -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. - `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. ```yaml diff --git a/docs/widgets/info/search.md b/docs/widgets/info/search.md index bb6acbec..3555a13b 100644 --- a/docs/widgets/info/search.md +++ b/docs/widgets/info/search.md @@ -9,6 +9,7 @@ You can add a search bar to your top widget area that can search using Google, D - search: provider: google # google, duckduckgo, bing, baidu, brave or custom 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 ``` diff --git a/src/components/quicklaunch.jsx b/src/components/quicklaunch.jsx index 908d1ee9..69f66eb0 100644 --- a/src/components/quicklaunch.jsx +++ b/src/components/quicklaunch.jsx @@ -1,6 +1,7 @@ import { useTranslation } from "react-i18next"; import { useEffect, useState, useRef, useCallback, useContext } from "react"; import classNames from "classnames"; +import useSWR from "swr"; import ResolvedIcon from "./resolvedicon"; @@ -15,10 +16,19 @@ export default function QuickLaunch({ searchProvider, }) { const { t } = useTranslation(); + + const { data: widgets } = useSWR("/api/widgets"); + const searchWidget = Object.values(widgets).find((w) => w.type === "search"); + const { settings } = useContext(SettingsContext); - const { searchDescriptions, hideVisitURL, showSearchSuggestions } = settings?.quicklaunch + const { searchDescriptions, hideVisitURL } = 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();