fireShortcut ignores the overlay a keydown comes from

Aperta
#331 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, typescript
Ambito
testing

Direzione di ricerca

Start with matchKeydown in Flow's Shortcut.ts to see how the browser scopes keydowns to open overlays, then with KeydownFilterSimulation and its unused checkOwnerScope. The origin of a keydown comes from FocusTracker, and the owner's overlay comes from ownerSelector in fireShortcut. Done when a shortcut in a non-modal Dialog or Popover fires only when the focus position matches the browser table in the issue, and existing tests are updated accordingly.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Problem

fireShortcut does not check where the keydown comes from. In the browser,
the shortcut filter (matchKeydown in Flow's Shortcut.ts) ignores a
keydown that does not originate from the popover/modal scope of the shortcut
owner: while a non-modal Dialog or a Popover is open, a keydown inside
it only reaches shortcuts owned inside it, and a keydown outside it only
reaches shortcuts owned outside it. KeydownFilterSimulation ignores
checkOwnerScope, so browserless fires every shortcut the server allows,
and a test can pass for a shortcut a real user cannot trigger.

Modal dialogs are not affected: the server makes the UI inert, so the
shortcuts outside the dialog are not notified in either case.

Raised in the review of #326. Not a regression of that PR: the old
simulation did not check the scope either.

Reproduction

A view with Alt+digit click shortcuts on buttons in the view ("main"), in a
modal Dialog ("modal"), in a non-modal Dialog ("nonmodal") and in a
Popover ("popover"), plus a shortcut listener owned by the UI ("ui"). Each
scenario presses all of them, in Chrome against Vaadin 25.4-SNAPSHOT, and
with fireShortcut:

Scenario Browser Browserless Same?
No overlay, focus in the view main, popover, ui main, popover, ui yes
Modal Dialog open, focus in it modal modal yes
Non-modal Dialog open, focus in it nonmodal main, nonmodal, popover, ui no
Non-modal Dialog open, focus in the view main, popover, ui main, nonmodal, popover, ui no
Popover open, focus in it popover main, popover, ui no
Popover open, focus in the view main, ui main, popover, ui no

("popover" fires with the popover closed in both: its button is then not
inside an open overlay.)

Browserless fires the union, which no focus position in the browser
produces.

Proposed fix

Browserless already tracks focus with FocusTracker, so no new API is
needed:

  • Take the origin of the keydown from the focused component. When nothing is
    focused, use the active modal component if there is one, since the
    browser traps focus there, and otherwise the top level.
  • In the keydown simulation, compare the nearest open overlay (Dialog,
    Popover) around the origin with the one around the shortcut owner,
    found from ownerSelector. A shortcut owned by the UI requires the origin
    to be at the top level.

A test then states where the user is, as in the browser:
test(fieldInDialog).focus() or any interaction with a component in the
overlay, followed by fireShortcut(...).

This changes what existing tests see: a test that fires a shortcut owned in
a non-modal dialog or popover without anything in it focused no longer
fires it.

Lingua principale
Java
Stelle
1
Fork
3
Merge medio
2g 1h
PR unite (30g)
24

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vaadin/browserless-test

Tutte le issue di vaadin/browserless-test

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.