Scanner run preview dismissal does not restore keyboard focus

Abierto Apto para principiantes
#2,680 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
playwright, typescript

Línea de trabajo

Comienza en frontend/src/components/Scenarios/ScenarioDetail.tsx, en el estado del diálogo de vista previa, onOpenChange y el controlador de Cancel. Ejecuta la prueba focalizada de Playwright para la desestimación descrita en el issue para Cancel y Escape, y luego añade cobertura de regresión que muestre que ambas rutas restauran el foco en el botón con data-testid="launch-scenario-btn".

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug: triage
Describe the bug

Dismissing Scanner's Run preview dialog with either Cancel or Escape leaves document.activeElement on <body> instead of returning focus to the Launch scan button that opened the modal.

The dialog initially receives and contains focus correctly. The defect is specific to focus restoration after dismissal. Keyboard users lose their point of reference and must navigate back to the launch workflow before continuing.

A search of currently open issues and pull requests using Scanner, run preview, dialog, focus restoration, and keyboard terms found no exact tracker. #2653 discusses decomposing ScenarioDetail while preserving accessibility, but it does not describe this behavior.

The relevant state-controlled dialog is in frontend/src/components/Scenarios/ScenarioDetail.tsx:1216-1223,1228-1234,1322-1327. Both onOpenChange and the Cancel handler close the dialog by updating previewOpen; neither path restores focus to the launch control.

Steps/Code to Reproduce
  1. Open Scanners and select airt.jailbreak.
  2. Select any configured compatible target.
  3. Select baseline plus prompt_sending, set num_jailbreaks=1, num_jailbreak_attempts=1, and set the maximum dataset size to 1.
  4. Activate Launch scan to open Run preview.
  5. Select Cancel, wait for the dialog to close, and inspect document.activeElement.
  6. Reopen Run preview, dismiss it with Escape, and inspect document.activeElement again.

The focused Playwright probe used for both dismissal paths was:

await page.getByRole('button', { name: 'Cancel' }).click()
await page.waitForTimeout(300)

const activeElement = await page.evaluate(() => ({
  tag: document.activeElement?.tagName,
  testId: document.activeElement?.getAttribute('data-testid'),
  ariaLabel: document.activeElement?.getAttribute('aria-label'),
}))

// { tag: 'BODY', testId: null, ariaLabel: null }

The same result reproduced after pressing Escape.

Expected Results

After either Cancel or Escape closes Run preview, focus returns to the Launch scan button (data-testid="launch-scenario-btn") that opened the dialog.

Actual Results

After both dismissal paths:

document.activeElement.tagName: BODY
data-testid: null
aria-label: null

The behavior reproduced in two focused runs with a 300 ms wait after dismissal. No scan was launched.

A likely fix is to retain a ref to the launch button and restore focus after every non-submitting dismissal path, with regression coverage for both Cancel and Escape.

Screenshots

N/A. The modal renders correctly; the failure is the programmatic focus position after it closes. The exact active-element result is included above.

Versions
  • OS: Windows_NT
  • Browser: Playwright Chromium (@playwright/test 1.62.1)
  • Python: 3.14.4
  • PyRIT: 1.2.0.dev0, main at b0dba3edd0abc2a88c15a5e8ebd106fe8396d27d
  • Python package versions: repository uv.lock at the tested commit
Lenguaje dominante
Python
Estrellas
4.5k
Forks
896
Merge medio
3 d 7 h
PR fusionados (30 d)
155

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/PyRIT

Todos los issues de microsoft/PyRIT

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.