Skip to content

Commit

Permalink
fix(cli): re-enable space key for multiselect prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
xeno097 committed Nov 1, 2024
1 parent 2f04959 commit d000dc2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion typescript/cli/src/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function runMultiChainSelectionStep({
? { ...choice, checked: true }
: choice,
),
instructions: `Use TAB key to select at least ${requireNumber} chains, then press ENTER to proceed. Type to search for a specific chain.`,
instructions: `Use the TAB or the SPACE key to select at least ${requireNumber} chains, then press ENTER to proceed. Type to search for a specific chain.`,
theme: {
style: {
// The leading space is needed because the help tip will be tightly close to the message header
Expand Down
13 changes: 8 additions & 5 deletions typescript/cli/src/utils/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
useState,
} from '@inquirer/core';
import figures from '@inquirer/figures';
import { KeypressEvent, confirm, input } from '@inquirer/prompts';
import { KeypressEvent, confirm, input, isSpaceKey } from '@inquirer/prompts';
import type { PartialDeep } from '@inquirer/type';
import ansiEscapes from 'ansi-escapes';
import chalk from 'chalk';
Expand Down Expand Up @@ -373,9 +373,9 @@ function getHelpTips({
let helpTipBottom = '';
const defaultTopHelpTip =
instructions ??
`(Press ${theme.style.key('tab')} to select, and ${theme.style.key(
'enter',
)} to proceed`;
`(Press ${theme.style.key('tab')} or ${theme.style.key(
'space',
)} to select, and ${theme.style.key('enter')} to proceed`;
const defaultBottomHelpTip = `\n${theme.style.help(
'(Use arrow keys to reveal more choices)',
)}`;
Expand Down Expand Up @@ -587,7 +587,10 @@ export const searchableCheckBox = createPrompt(
);
setActive(next);
}
} else if (key.name === 'tab' && optionState.options.length > 0) {
} else if (
(key.name === 'tab' || isSpaceKey(key)) &&
optionState.options.length > 0
) {
// Avoid the message header to be printed again in the console
rl.clearLine(0);

Expand Down

0 comments on commit d000dc2

Please sign in to comment.