From 954744f386313635db71a57b398af60822235ee7 Mon Sep 17 00:00:00 2001 From: Amal Mathew Date: Tue, 19 Mar 2024 09:32:39 +0530 Subject: [PATCH] #5440: Fix Up arrow key in terminal --- components/lib/terminal/Terminal.vue | 7 ++++++- doc/terminal/AccessibilityDoc.vue | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/lib/terminal/Terminal.vue b/components/lib/terminal/Terminal.vue index d9a3e18553..8e7c0bdc20 100755 --- a/components/lib/terminal/Terminal.vue +++ b/components/lib/terminal/Terminal.vue @@ -26,7 +26,8 @@ export default { data() { return { commandText: null, - commands: [] + commands: [], + currentCommandIdx: -1 }; }, mounted() { @@ -48,6 +49,10 @@ export default { this.commands.push({ text: this.commandText }); TerminalService.emit('command', this.commandText); this.commandText = ''; + this.currentCommandIdx = this.commands.length - 1; + } else if (event.key === 'ArrowUp' && this.currentCommandIdx > -1) { + this.commandText = this.commands[this.currentCommandIdx].text; + this.currentCommandIdx--; } }, responseListener(response) { diff --git a/doc/terminal/AccessibilityDoc.vue b/doc/terminal/AccessibilityDoc.vue index 861b87cddc..ab8c5d036c 100644 --- a/doc/terminal/AccessibilityDoc.vue +++ b/doc/terminal/AccessibilityDoc.vue @@ -25,6 +25,12 @@ Executes the command when focus in on the input element. + + + up + + Recall previously entered commands to the terminal. +