From e5d36b82bbe0a34b743d75456c97b26b86de2a24 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 23 Feb 2024 18:00:30 +0800 Subject: [PATCH] Fix search suggestion sort --- src/components/search-form.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/search-form.jsx b/src/components/search-form.jsx index 5a57b304..22ca88a0 100644 --- a/src/components/search-form.jsx +++ b/src/components/search-form.jsx @@ -219,6 +219,7 @@ const SearchForm = forwardRef((props, ref) => { hidden: /^https?:/.test(query), top: /\s/.test(query), icon: 'document', + queryType: 'statuses', }, { label: ( @@ -232,6 +233,7 @@ const SearchForm = forwardRef((props, ref) => { top: /^#/.test(query), type: 'link', icon: 'hashtag', + queryType: 'hashtags', }, { label: ( @@ -252,9 +254,14 @@ const SearchForm = forwardRef((props, ref) => { ), to: `/search?q=${encodeURIComponent(query)}&type=accounts`, icon: 'group', + queryType: 'accounts', }, ] .sort((a, b) => { + if (type) { + if (a.queryType === type) return -1; + if (b.queryType === type) return 1; + } if (a.top && !b.top) return -1; if (!a.top && b.top) return 1; return 0;