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

Shared Blocks: Fix editing paragraph blocks #7077

Merged
merged 1 commit into from Jun 4, 2018

Conversation

Projects
None yet
3 participants
@youknowriad
Contributor

youknowriad commented Jun 1, 2018

closes #7075

Right now editing shared blocks is broken because when we render the Autocomplete component (used in paragraph blocks), we're triggering a "fetch shared blocks" request. This requests is causing the uid of the block attached to the shared block to be regenerated which means the block will rerender (considered as a different block) and the loop continues.

The root cause of the issue is not fixed in this PR, this is a hacky fix will small implications than can land in 3.0 but as a follow-up I'm planning to fix the root issue which is the fact that we have a cycle dependency in our shared blocks state.

sharedBlock.id => block.uid relation
and
block.uid => sharedBlock.id

This cycle is forcing us to regenerate the block attached to the shared block when we fetch them.

@youknowriad youknowriad added this to the 3.0 milestone Jun 1, 2018

@youknowriad youknowriad self-assigned this Jun 1, 2018

@youknowriad youknowriad requested review from mcsf, brandonpayton and noisysocks Jun 1, 2018

@mcsf

mcsf approved these changes Jun 1, 2018

Thanks for the quick fix + proper fix. LGTM.

@mcsf

This comment has been minimized.

Contributor

mcsf commented Jun 1, 2018

Regarding the failing tests: the fact that we now always fetch shared blocks means that RECEIVE_BLOCKS will be dispatched via RECEIVE_SHARED_BLOCKS. As a result, core/editor::editor.past receives a history snapshot and the Undo button becomes enabled because hasEditorUndo( state ) === state.editor.past.length > 0 === true.

This isn't an issue introduced in this PR (nor in the previous PR working on the autocompleter, IMO), but it exposes the root problem: that adding block knowledge (awareness of available shared blocks) to our application (even when said blocks are not impacting the post) is treated as an editor change.

@noisysocks

Nice hack 👍

@youknowriad

This comment has been minimized.

Contributor

youknowriad commented Jun 4, 2018

I updated the hack to avoid the initial "history". It's still hacky though. Let's get this in and see how we can fi the shared blocks root state issue later.

@youknowriad youknowriad merged commit 80864d4 into master Jun 4, 2018

2 checks passed

codecov/project 46.35% (+<.01%) compared to 6a7085b
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@youknowriad youknowriad deleted the fix/editing-shared-paragraph-bloocks branch Jun 4, 2018

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