Skip to content

Conversation

@samuelgja
Copy link
Contributor

Description

Fixes link flickering issue where links would briefly appear before element content was rendered.

Motivation and Context

The Bug: When rendering a Paper with elements and links, the visual sequence was:

  1. Frame 1: Empty screen
  2. Frame 2: Only links visible (pointing to positions, but no element content)
  3. Frame 3: Correct render with both elements and links

This happened because JointJS renders link SVG paths synchronously, while React portals render element content via microtask (later).

Changes

  • Refactored create-elements-size-observer.ts to ensure consistent timing between link paths and element content
  • Added comprehensive test suite (paper-link-flickering.test.tsx) that verifies the invariant: "If links are visible with rendered paths, elements must also have their content rendered"
  • Added unit tests for the size observer

…intJS elements and links

- Add BatchCache class for managing batched updates for links, ports, and clear views.
- Introduce ClearViewCacheEntry and related functions for managing clear view updates.
- Create PortUpdateCacheEntry and functions for merging port updates and groups.
- Implement state flushing functions to handle element and link updates in a React-friendly manner.
- Develop example story demonstrating cell actions with dynamic node and link management.
- Define GraphSchedulerData type for unified scheduling of updates across elements, links, and ports.
…in various components and tests

- Updated GraphProvider stories to remove 'id' from elements and links.
- Cleaned up highlighter tests by removing 'id' from element definitions.
- Adjusted stroke highlighter tests to eliminate 'id' from elements.
- Modified paper tests to remove 'id' from elements and links.
- Refactored port tests to exclude 'id' from elements.
- Updated hooks tests to remove 'id' from elements.
- Cleaned up model tests by removing 'id' from ReactElement and ReactLink instances.
- Adjusted example stories to remove 'id' from elements and links.
@samuelgja samuelgja requested a review from kumilingus January 30, 2026 09:52
@samuelgja samuelgja marked this pull request as draft January 30, 2026 09:54
@samuelgja samuelgja force-pushed the fix/react-observer-fix branch from 791bf5a to 33b456b Compare January 30, 2026 14:27
@samuelgja samuelgja marked this pull request as ready for review January 30, 2026 14:36
type ReactPaperOptionsBase = OmitWithoutIndexSignature<
dia.Paper.Options,
'frozen' | 'defaultLink' | 'autoFreeze' | 'viewManagement'
'frozen' | 'defaultLink' | 'autoFreeze' | 'viewManagement' | 'measureNode'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this @kumilingus

@@ -0,0 +1,288 @@
/* eslint-disable prefer-destructuring */
Copy link
Contributor Author

@samuelgja samuelgja Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add immediate handling when an element is added to the observer.
The observer is attached instantly, but it only detects changes on the next animation frame.
To eliminate this delay, we immediately measure the HTML element, while still processing measurements in a batch.

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.

2 participants