diff --git a/website/replays/src/replays-battle.tsx b/website/replays/src/replays-battle.tsx index 023ae7c09c..6363567bbf 100644 --- a/website/replays/src/replays-battle.tsx +++ b/website/replays/src/replays-battle.tsx @@ -72,7 +72,8 @@ export class BattlePanel extends preact.Component<{id: string}> { } | null | undefined = undefined; battle: Battle | null; speed = 'normal'; - keyCode = '0'; + /** debug purposes */ + lastUsedKeyCode = '0'; turnView: boolean | string = false; autofocusTurnView: 'select' | 'end' | null = null; override componentDidMount() { @@ -143,7 +144,8 @@ export class BattlePanel extends preact.Component<{id: string}> { } keyPressed = (e: KeyboardEvent) => { // @ts-ignore - this.keyCode = `${e.keyCode}`; + this.lastUsedKeyCode = `${e.keyCode}`; + if (e.ctrlKey || e.metaKey || e.altKey) return; if (e.keyCode === 27 && this.turnView) { // Esc this.closeTurn(); return; @@ -190,8 +192,8 @@ export class BattlePanel extends preact.Component<{id: string}> { ); } break; - case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: - case 96: case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104: case 105: + case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 0-9 + case 96: case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104: case 105: // numpad 0-9 this.turnView = String.fromCharCode(e.keyCode - (e.keyCode >= 96 ? 48 : 0)); if (this.turnView === '0') this.turnView = '10'; this.autofocusTurnView = 'end'; diff --git a/website/replays/src/replays.tsx b/website/replays/src/replays.tsx index e78865f95f..1648832708 100644 --- a/website/replays/src/replays.tsx +++ b/website/replays/src/replays.tsx @@ -35,7 +35,8 @@ class SearchPanel extends preact.Component<{id: string}> { }); this.updateSearch(Net.decodeQuery(this.props.id)); } - override componentDidUpdate() { + override componentDidUpdate(previousProps: this['props']) { + if (this.props.id === previousProps.id) return; const query = Net.decodeQuery(this.props.id); const page = parseInt(query.page || '1'); const byRating = (query.sort === 'rating'); @@ -111,7 +112,7 @@ class SearchPanel extends preact.Component<{id: string}> { }); } modLink(overrides: {page?: number, sort?: string}) { - const newPage = this.page + (overrides.page || 0); + const newPage = (overrides.page !== undefined ? this.page + overrides.page : 1); return './?' + Net.encodeQuery({ user: this.user || undefined, format: this.format || undefined, @@ -185,46 +186,56 @@ class SearchPanel extends preact.Component<{id: string}> { ))} ; - return