diff --git a/app/src/Tags.js b/app/src/Tags.js index c9296ded..5e0b6a20 100644 --- a/app/src/Tags.js +++ b/app/src/Tags.js @@ -425,8 +425,23 @@ export function AddTagsButton({ if (open) { setFilterText(''); setHasSelectedTag(false); - setFrequentTagsLabel('Recent Tags'); - getRecentTags().then(names => setFrequentTags(names)); + if (selectedTagNames && selectedTagNames.length === 1) { + setHasSelectedTag(true); + getCooccurringTags(selectedTagNames[0]).then(coTags => { + if (coTags && coTags.length > 0) { + setFrequentTags(coTags); + setFrequentTagsLabel('Frequent Tags'); + } else { + setFrequentTags([]); + setFrequentTagsLabel('Recent Tags'); + } + }); + } else if (!selectedTagNames || selectedTagNames.length === 0) { + setFrequentTagsLabel('Recent Tags'); + getRecentTags().then(names => setFrequentTags(names)); + } else { + setFrequentTags([]); + } const timeout = setTimeout(() => { if (filterInputRef.current && window.innerWidth >= 700) { filterInputRef.current.focus(); @@ -456,12 +471,14 @@ export function AddTagsButton({ setFilterText(''); onAdd(name); onChange(newTags, null); - if (!hasSelectedTag && newTags.length === 1) { + if (!hasSelectedTag) { setHasSelectedTag(true); getCooccurringTags(name).then(coTags => { if (coTags && coTags.length > 0) { setFrequentTags(coTags); setFrequentTagsLabel('Frequent Tags'); + } else { + setFrequentTags([]); } }); } diff --git a/wrolpi/root_api.py b/wrolpi/root_api.py index f5832046..fe6201bf 100644 --- a/wrolpi/root_api.py +++ b/wrolpi/root_api.py @@ -1,6 +1,7 @@ import asyncio import pathlib import re +import urllib.parse from http import HTTPStatus import vininfo.exceptions @@ -542,6 +543,7 @@ async def get_recent_tags_request(_: Request): description='Get tags that frequently co-occur with the given tag', ) async def get_cooccurring_tags_request(_: Request, tag_name: str): + tag_name = urllib.parse.unquote(tag_name) tag_names = tags.get_cooccurring_tags(tag_name) return json_response(dict(tag_names=tag_names))