@readium/navigator-html-injectables 2.4.2 → 2.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/navigator-html-injectables",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "type": "module",
5
5
  "description": "An embeddable solution for connecting frames of HTML publications with a Readium Navigator",
6
6
  "author": "readium",
@@ -79,6 +79,10 @@ export function isInteractiveElement(element: Element | null): boolean {
79
79
  // Check for interactive roles
80
80
  if (element.role && interactiveRoles.includes(element.role)) return true;
81
81
 
82
+ // An iframe element is a separate browsing context — its focused content cannot be inspected
83
+ // cross-origin, so the iframe container itself must not be treated as interactive.
84
+ if (element.tagName.toLowerCase() === "iframe") return false;
85
+
82
86
  if ((element as HTMLElement).tabIndex >= 0) return true;
83
87
 
84
88
  // Use existing interactive tags logic
@@ -146,6 +146,7 @@ export class KeyCombinationManager {
146
146
  const handlers = this.createKeyboardHandlers(targetFrameSrc, shortcuts, dispatcher, wnd);
147
147
 
148
148
  return (event: KeyboardEvent) => {
149
+ if (!event.isTrusted) return;
149
150
  for (const handlerConfig of handlers) {
150
151
  if (this.match(event, [handlerConfig])) {
151
152
  const suppress = handlerConfig.suppressOnInteractiveElement;
@@ -537,6 +537,15 @@ export class Peripherals extends Module {
537
537
  ack(true);
538
538
  });
539
539
 
540
+ // Disable keyboard handler when frame is unfocused so that stale focus
541
+ // inside a hidden/off-screen iframe doesn't silently swallow key events
542
+ // through a halted comms channel. The handler is re-established on the
543
+ // next show() cycle via the keyboard_peripherals message below.
544
+ this.comms?.register("unfocus", Peripherals.moduleName, (_, ack) => {
545
+ this.disableKeyboardPeripherals();
546
+ ack(true);
547
+ });
548
+
540
549
  // Separate handler for keyboard peripherals
541
550
  this.comms?.register("keyboard_peripherals", Peripherals.moduleName, (data: unknown, ack) => {
542
551
  const keyboardPeripherals = data as KeyboardPeripheral[];