search rank in tournament without the # prefix - for #9551

370417-search-rank
Thibault Duplessis 2021-08-11 10:30:33 +02:00
parent 4f119be27f
commit 8c3cb49374
3 changed files with 4 additions and 4 deletions

View File

@ -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,
});
}

View File

@ -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, () => {

View File

@ -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();