Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(canvas): Avoid rerendering the entire application when configuring nodes #433

Merged

Conversation

lordrip
Copy link
Member

@lordrip lordrip commented Nov 28, 2023

Context

Currently, when configuring a node in the canvas, it refreshes the source code. This in turn forces the rerendering of the entire application, as the SourceCode provider holds the source code state and is placed at the root.

Changes

The fix is to split the provider into SourceCodeContext and SourceCodeApiContext, this way the consumers can subscribe only to the required section avoiding having a reference to the changing source code.

A few consumer examples:

  • FlowClipboard component: it only needs access to the source code.
  • NewFlow: it only needs access to the SourceCodeApi to signal that something changed
  • Shell: it only needs access to the entities:updated signal to save the code to localStorage
  • KaotoEditor and SourceCodePage: needs both context

Before

Updating.entire.UI.webm

After

Screencast.from.2023-11-28.11-31-55.webm

Fixes: #213

…g nodes

Currently, when configuring a node in the canvas, it refresh the source code. This in turn
force rerendering the entire application, as the SourceCode provider holds the source code
state and its placed at the root.

The fix is to split the provider into SourceCodeContext and SourceCodeApiContext, this way
the consumers can subscribe only to the required section avoiding having a reference to the
changing source code.

A few consumers examples:
* FlowClipboard component: it only needs access to the source code.
* NewFlow: it only needs access to the SourceCodeApi to signal that something changed
* Shell: it only needs access to the `entities:updated` signal to save the code to localStorage
* KaotoEditor and SourceCodePage: needs both context

Fixes: KaotoIO#213
@lordrip lordrip force-pushed the fix/avoid-rerendering-when-configuring-node branch from 8dc185f to 02b08ec Compare November 28, 2023 10:52
@lordrip lordrip merged commit f02a61f into KaotoIO:main Nov 28, 2023
10 checks passed
@lordrip lordrip deleted the fix/avoid-rerendering-when-configuring-node branch November 30, 2023 16:21
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.

The entire UI rerenders upon updating a node
2 participants