From 8c3cb49374d7015fdeeee16591431706c86b843b Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Wed, 11 Aug 2021 10:30:33 +0200 Subject: [PATCH] search rank in tournament without the # prefix - for #9551 --- ui/site/src/userComplete.ts | 2 +- ui/tournament/src/ctrl.ts | 1 - ui/tournament/src/search.ts | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/site/src/userComplete.ts b/ui/site/src/userComplete.ts index 52d5ba67b4..8bd15edd33 100644 --- a/ui/site/src/userComplete.ts +++ b/ui/site/src/userComplete.ts @@ -64,6 +64,6 @@ export default function (opts: Opts): void { }, populate: opts.populate || (r => r.name), onSelect: opts.onSelect, - regex: /^[a-z0-9][\w-]{2,29}$/i, + regex: /^[a-z][\w-]{2,29}$/i, }); } diff --git a/ui/tournament/src/ctrl.ts b/ui/tournament/src/ctrl.ts index e4c7a4dfb2..16863bbcf2 100644 --- a/ui/tournament/src/ctrl.ts +++ b/ui/tournament/src/ctrl.ts @@ -112,7 +112,6 @@ export default class TournamentController { }; jumpToRank = (rank: number) => { - if (!Number.isInteger(rank) || rank < 1) return; const page = 1 + Math.floor((rank - 1) / maxPerPage); const row = (rank - 1) % maxPerPage; xhr.loadPage(this, page, () => { diff --git a/ui/tournament/src/search.ts b/ui/tournament/src/search.ts index ac6c689aa0..a7045d383e 100644 --- a/ui/tournament/src/search.ts +++ b/ui/tournament/src/search.ts @@ -32,8 +32,9 @@ export function input(ctrl: TournamentController): VNode { el.focus(); }); $(el).on('keydown', e => { - if (e.code === 'Enter' && el.value.startsWith('#')) { - ctrl.jumpToRank(Number(el.value.slice(1))); + if (e.code === 'Enter') { + const rank = parseInt(e.target.value); + if (rank > 0) ctrl.jumpToRank(rank); } if (e.code === 'Escape') { ctrl.toggleSearch();