From 2902d1e9d193a157bccd46cdda449de5443a2fd8 Mon Sep 17 00:00:00 2001 From: wxiaoguang <wxiaoguang@gmail.com> Date: Sat, 15 Apr 2023 03:29:05 +0800 Subject: Sort repo topic labels by name (#24123) Close #24077 --- web_src/js/features/repo-home.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'web_src') diff --git a/web_src/js/features/repo-home.js b/web_src/js/features/repo-home.js index e08e84b393..55a2771054 100644 --- a/web_src/js/features/repo-home.js +++ b/web_src/js/features/repo-home.js @@ -41,6 +41,7 @@ export function initRepoTopicBar() { viewDiv.children('.topic').remove(); if (topics.length) { const topicArray = topics.split(','); + topicArray.sort(); for (let i = 0; i < topicArray.length; i++) { const link = $('<a class="ui repo-topic large label topic"></a>'); link.attr('href', `${appSubUrl}/explore/repos?q=${encodeURIComponent(topicArray[i])}&topic=1`); @@ -57,12 +58,12 @@ export function initRepoTopicBar() { topicPrompts.formatPrompt = xhr.responseJSON.message; const {invalidTopics} = xhr.responseJSON; - const topicLables = topicDropdown.children('a.ui.label'); + const topicLabels = topicDropdown.children('a.ui.label'); for (const [index, value] of topics.split(',').entries()) { for (let i = 0; i < invalidTopics.length; i++) { if (invalidTopics[i] === value) { - topicLables.eq(index).removeClass('green').addClass('red'); + topicLabels.eq(index).removeClass('green').addClass('red'); } } } -- cgit v1.2.3