From 24d422934964f981ab1ed79f479a66fb67d47b25 Mon Sep 17 00:00:00 2001 From: Karthik <32044378+Karthik99999@users.noreply.github.com> Date: Tue, 24 Oct 2023 11:20:37 -0700 Subject: [PATCH] Format Selector: Hide categories with no matches from search (#2169) --- js/client-mainmenu.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js index fa95111cc7..5b269b552e 100644 --- a/js/client-mainmenu.js +++ b/js/client-mainmenu.js @@ -1256,7 +1256,7 @@ var bufs = []; var curBuf = 0; - if (selectType === 'watch') { + if (selectType === 'watch' && !this.search) { bufs[1] = '
'; } @@ -1269,6 +1269,7 @@ if (format.effectType !== 'Format' || format.battleFormat) continue; if (selectType != 'watch' && !format[selectType + 'Show']) continue; } + if (this.search && !format.id.includes(toID(this.search))) continue; if (format.section && format.section !== curSection) { if (curSection) bufs[curBuf] += ''; @@ -1287,7 +1288,6 @@ bufs[curBuf] += BattleLog.escapeHTML(curSection) + ''; } var formatName = BattleLog.escapeFormat(format.id); - if (this.search && !format.id.includes(toID(this.search))) continue; if (formatName.charAt(0) !== '[') formatName = '[Gen 6] ' + formatName; formatName = formatName.replace('[Gen 9] ', ''); formatName = formatName.replace('[Gen 9 ', '['); @@ -1296,16 +1296,21 @@ bufs[curBuf] += ''; } var html = ''; - for (var i = 1, l = bufs.length; i < l; i++) { - html += ' '; } return html; },