Skip to content

latex editor: PDF (Native) frame crashes in Opera via jQuery leverageNative #8859

Description

@haraldschilly

Summary

The "PDF (Native)" frame in the LaTeX editor (src/packages/frontend/frame-editors/latex-editor/pdf-embed.tsx) calls jQuery's .focus() on the <embed type="application/pdf"> element:

function focus(): void {
  actions.set_active_id(id);
  $(embedRef.current).focus();
}

This routes the focus event through jQuery 3's leverageNative shim (the code that makes focus/blur/click bubble on elements that don't natively bubble them). In Opera, the bundled PDF plugin on that <embed> fires synthetic events that re-enter the shim and corrupt the value jQuery stored in its private data slot. The next dispatch then crashes with:

TypeError: H.slice is not a function
  at HTMLEmbedElement.handler (jQuery event.trigger leverageNative path)

Reported on an onprem install (cocalc.gwdg.de, Opera 130), triggered by mousing over the PDF pane after a build (the onMouseEnter={focus} overlay).

Fix

Drop the jQuery wrapper and call the native DOM focus() directly — no leverageNative path, no jQuery-3 recursion bug:

function focus(): void {
  actions.set_active_id(id);
  embedRef.current?.focus?.();
}

No behavior change expected on Chrome/Firefox; fixes Opera.

Workaround for users on old builds

Switch the frame tab from "PDF (Native)" to "PDF - Preview" (PDF.js), or use Chrome/Firefox.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions