fireShortcut ignores the overlay a keydown comes from

オープン
#331 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java, typescript
領域
testing

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Java
スター
1
フォーク
3
平均マージ
2日 1時間
マージ済み PR(30日)
24

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vaadin/browserless-test のほかの issue

vaadin/browserless-test の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。