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

[reports] Refactor Block Editor Flow #1348

Open
4 of 8 tasks
greenrhyno opened this issue Feb 11, 2022 · 1 comment
Open
4 of 8 tasks

[reports] Refactor Block Editor Flow #1348

greenrhyno opened this issue Feb 11, 2022 · 1 comment
Assignees
Milestone

Comments

@greenrhyno
Copy link
Contributor

greenrhyno commented Feb 11, 2022

Currently, the components that are responsible for editing blocks are (quasi) controlled -- they are passed a blockContent object which represents the latest edited state of a block's content (like its js logic and other metadata). These block-editing components are also passed a setter (setBlockContent) which is used to change the object they are passed. This is causing a number of unnecessary renders to be triggered because this blockContent object is constantly changing (sometimes on keystroke!).

Refactor the data flow of these block editors and the Block data flow to avoid unnecessary rerenders and make the components of Blocks (renderer, simple ui, adapter) less reliant on lots of props from ancestors so that they are easier to implement as plugins in the future.

Some things to do:

  • Add debouncer to blockContent so setBlockContent callback does not trigger so many rerenders
  • Make simple ui editors uncontrolled so they don't rely on blockContent prop
  • Don't unmount the "simple" editor when switching modes so they can maintain state when switching modes
  • make config objects for blocks that can configure behavior (like rendering preview on local state vs only on save)
  • make config flag that allows for rendering on client side only
  • add execute button to simple UI if block type renders only on save
  • consolidate logic in BlockPreview so that all blocks are varSwapped, mortarEval'd, then adapted
  • consolidate cms.js consts into the config objects for Blocks
@greenrhyno greenrhyno added this to the CMS 1.0 milestone Feb 11, 2022
@greenrhyno greenrhyno self-assigned this Feb 11, 2022
@greenrhyno
Copy link
Contributor Author

A diagram from a discussion about the new flow:
IMG_0714

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant