Skip to content

fix(cli): replace dialoguer drop prompt with line-based read for accessibility#4238

Open
BootstrapperSBL wants to merge 1 commit intolaunchbadge:mainfrom
BootstrapperSBL:fix/accessible-drop-prompt
Open

fix(cli): replace dialoguer drop prompt with line-based read for accessibility#4238
BootstrapperSBL wants to merge 1 commit intolaunchbadge:mainfrom
BootstrapperSBL:fix/accessible-drop-prompt

Conversation

@BootstrapperSBL
Copy link
Copy Markdown

Summary

Replaces the dialoguer::Confirm prompt in sqlx database drop with a plain stdin().read_line so that screen readers, large-print users, and anyone relying on terminal echo get predictable behaviour. Closes #4236.

Why

As reported in #4236, the existing prompt uses dialoguer::Confirm with wait_for_newline(true). In that mode dialoguer still puts the terminal into raw input for the Y/N toggle, which causes two separate failure modes:

  • Wrapped prompt (large print / narrow terminal): each keypress redraws the whole prompt to flip [Y/n][y/N], and screen readers re-parse the full line each time.
  • Single-line prompt (wide terminal): keypresses silently flip the default marker with no visual echo and no audible announcement — the user has no feedback that their input registered.

In both cases the pressed key is never displayed and there's no explicit "press Enter" cue.

What changed

  • ask_to_continue_drop now writes the prompt with an explicit (y/N) hint and reads a line from stdin.
  • No raw mode → keypresses echo naturally, Enter is the only implicit terminator, and screen readers get a normal line-at-a-time interaction.
  • The RestoreCursorGuard is gone because the cursor is never hidden.
  • --force / -y / non-TTY behaviour is unchanged (only the interactive confirm=true path is touched).

A small pure parse_drop_response helper is introduced and unit-tested so the accept/reject matrix is exercised in CI.

Before / After

Before (wrapped prompt, with a screen reader):

? Drop database at postgres://…? [Y/n]  ← full prompt re-read on every Y press

After:

Drop database at postgres://…? (y/N): y

Keypress echoes, Enter commits, screen readers announce just the single line.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --manifest-path sqlx-cli/Cargo.toml -- -D warnings
  • cargo test --manifest-path sqlx-cli/Cargo.toml (3 unit + 8 add + 3 migrate tests pass)
  • Manual: echo y | cargo run -- database drop -D sqlite://test.db proceeds; echo n and empty input abort.

…ssibility

`sqlx database drop` used dialoguer's raw-mode Y/N toggle, which doesn't echo
keypresses and repaints on each press — which screen readers and large-print
users find disorienting (see the two failure modes described in launchbadge#4236).

Swap to a plain `stdin().read_line` with an explicit `(y/N)` hint: no raw mode,
keys echo naturally, and screen readers get a predictable line-at-a-time
interaction. `--force` / `-y` / non-TTY paths are unchanged.

Closes launchbadge#4236
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessibility: sqlx database drop prompt loop is disorienting for visually impaired users (no input echo, no indication that return is needed)

1 participant