Skip to content

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

Open
draedful wants to merge 1 commit intomainfrom
249-html-blocks-disappear-after-sequential-setentities-calls
Open

fix(Block): resolve HTML blocks disappearing after double setEntities#256
draedful wants to merge 1 commit 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;

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.

3 participants