fix(keys): a key a focused widget already handled fires no shortcut
The player's settings tabs switched tab on an arrow and prevented its default, yet the player's window listener still sought the video 10 s. dispatch() now skips a defaultPrevented key for every scope; listNav's private copy of the same guard goes.
This commit is contained in:
@@ -154,6 +154,21 @@ describe("dispatch", () => {
|
||||
expect(calls).toEqual([]);
|
||||
});
|
||||
|
||||
// E28 UAT: an arrow the player's settings tabs had already taken (they switch tab and prevent its
|
||||
// default) ALSO sought the video 10 s. A key a focused widget consumed is spent, for every scope.
|
||||
it("ignores a key a focused widget already handled", () => {
|
||||
const calls: string[] = [];
|
||||
const tab = document.createElement("button");
|
||||
tab.setAttribute("role", "tab");
|
||||
document.body.append(tab);
|
||||
tab.addEventListener("keydown", (e) => e.preventDefault());
|
||||
expect(dispatch(press({ key: "ArrowRight" }, tab), "plexPlayer", plexHandlers(calls))).toBe(
|
||||
false,
|
||||
);
|
||||
expect(calls).toEqual([]);
|
||||
tab.remove();
|
||||
});
|
||||
|
||||
// A `handledLocally` row is documentation + a shared chord, matched on the focused element by its
|
||||
// own component (Shift+F10 belongs to whichever row has focus). `dispatch` must not claim it, and
|
||||
// the mapped handler type must not demand one — this test is the runtime half of that.
|
||||
|
||||
Reference in New Issue
Block a user