Skip to content

fix(Block): resolve HTML blocks disappearing after double setEntities#256

Merged
draedful merged 2 commits intomainfrom
249-html-blocks-disappear-after-sequential-setentities-calls
Mar 2, 2026
Merged

fix(Block): resolve HTML blocks disappearing after double setEntities#256
draedful merged 2 commits intomainfrom
249-html-blocks-disappear-after-sequential-setentities-calls

Conversation

@draedful
Copy link
Collaborator

@draedful draedful commented Feb 27, 2026

The cause of the bug (issue #249)

When calling setEntities({blocks:[]}) + setEntities({blocks:[b1,b2]}), the following happened in a row:

  1. The first setEntities cleared the $blocksMap' → React redrawn GraphBlockwithstate = undefined→ renderednull`
  2. The second setEntities created new objects BlockStateGraphBlock received BlockState_new, but getViewComponent() returned undefined (canvas component has not connected yet) → rendered null again
  3. When canvas finally connected the component via setViewComponent(), React didn't know about it — ViewState was a regular variable, not a reactive one

@draedful draedful requested a review from Antamansid as a code owner February 27, 2026 10:01
@gravity-ui-bot
Copy link
Contributor

Preview is ready.

lastState.height = geometry.height;
}

const { zIndex, order } = viewState.$viewState.value;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't apply to PR, just jfyi: it doesn't check for viewstate, unlike in other places. It's probably worth adding a check on it on line 127.
like:

if (!container || !geometry || !viewState) return;

@draedful draedful force-pushed the 249-html-blocks-disappear-after-sequential-setentities-calls branch from 5c3ac3b to ec6f6c0 Compare March 2, 2026 21:03
@draedful draedful linked an issue Mar 2, 2026 that may be closed by this pull request
@draedful draedful force-pushed the 249-html-blocks-disappear-after-sequential-setentities-calls branch from e0a229c to ec17b68 Compare March 2, 2026 21:30
@draedful draedful merged commit 89e4fd2 into main Mar 2, 2026
5 checks passed
@draedful draedful deleted the 249-html-blocks-disappear-after-sequential-setentities-calls branch March 2, 2026 21:39
@gravity-ui gravity-ui bot mentioned this pull request Mar 2, 2026
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.

HTML blocks disappear after sequential setEntities calls

3 participants