Skip to content

Commit 8f821b0

Browse files
committed
feature: Show direct match on top for user search
- Fixes #14350 Signed-off-by: Maximilian Weiler <[email protected]>
1 parent 429258c commit 8f821b0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

web_src/js/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -2233,15 +2233,21 @@ function searchUsers() {
22332233
url: `${AppSubUrl}/api/v1/users/search?q={query}`,
22342234
onResponse(response) {
22352235
const items = [];
2236+
const searchQuery = $searchUserBox.find('input').val();
22362237
$.each(response.data, (_i, item) => {
22372238
let title = item.login;
22382239
if (item.full_name && item.full_name.length > 0) {
22392240
title += ` (${htmlEscape(item.full_name)})`;
22402241
}
2241-
items.push({
2242+
const resultItem = {
22422243
title,
22432244
image: item.avatar_url
2244-
});
2245+
};
2246+
if (searchQuery === item.login) {
2247+
items.unshift(resultItem);
2248+
} else {
2249+
items.push(resultItem);
2250+
}
22452251
});
22462252

22472253
return {results: items};

0 commit comments

Comments
 (0)