Skip to content

feat(dia.Paper): add focusin and focusout events - #3481

Open
kumilingus wants to merge 2 commits into
clientIO:devfrom
kumilingus:feat/paper-focus-events
Open

feat(dia.Paper): add focusin and focusout events#3481
kumilingus wants to merge 2 commits into
clientIO:devfrom
kumilingus:feat/paper-focus-events

Conversation

@kumilingus

@kumilingus kumilingus commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Description

Adds focusin/focusout paper events with the cell: / element: / link: variants, following the mouseover/mouseout pattern (same guard, same findView resolution, cell:* fired before element:*/link:* via the view notify chain).

focusin/focusout bubble natively, so the existing event delegation handles them without any special-event mapping. normalizeEvent is not applied (nothing to normalize on focus events). No blank: variants — a focus event outside of a cell view carries no useful information.

Motivation

Making cells keyboard-focusable (tabindex on the root via attrs) is a common accessibility approach; reacting to the focus currently requires a native DOM listener on paper.el. With this change:

paper.on('element:focusin', (elementView) => {
    // e.g. select the focused element
});

Changes

  • dia/Paper.mjsfocusin/focusout in the events hash + handlers
  • dia/CellView.mjs, dia/ElementView.mjs, dia/LinkView.mjsfocusin/focusout methods notifying cell:/element:/link: events
  • types/dia.d.ts — the 6 new event signatures
  • test/jointjs/paper.js — event order + no event outside of cell views (native bubbling FocusEvents; the test $.fn.trigger shim dispatches non-bubbling CustomEvents)
  • changeset (@joint/core: minor)

The paper turns the (bubbling) native focusin/focusout DOM events into
cell:/element:/link:/blank: paper events, following the mouseover/
mouseout pattern — so applications can react to keyboard focus on
cells (e.g. focusable cells via the root tabindex attribute) without
binding native DOM listeners on the paper element.
A focus event outside of a cell view carries no useful information —
keep the API surface to the cell:/element:/link: variants.
@kumilingus
kumilingus force-pushed the feat/paper-focus-events branch from a02a8fe to b9a30b8 Compare August 24, 2026 20:57
@kumilingus
kumilingus changed the base branch from master to dev August 24, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant