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(renderer): handle empty array as data.blocks #2454

Merged
merged 2 commits into from
Sep 5, 2023

Conversation

neSpecc
Copy link
Member

@neSpecc neSpecc commented Aug 24, 2023

Currently, if we pass [] as initial data or via blocks.render() editor will contain no-blocks at all. It will break the UX since redactorClicked will throw error:

Can not read property "holder" of undefined

const lastBlock = this.Editor.BlockManager.getBlockByIndex(-1);
const lastBlockBottomCoord = $.offset(lastBlock.holder).bottom;

Actually .getBlockByIndex() could return undefined (if we pass an unexisting index) — so I've added undefined as the return type. But in case of getting the last block by -1 it always should return a Block since it is expected that we always have at least one Block. So I've added overload for that case instead of checking on undefined in redactorClicked

Resolves #2084

@@ -1,5 +1,9 @@
# Changelog

### 2.29.0
Copy link
Member

Choose a reason for hiding this comment

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

Don't you want to publish it as a patch version?

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe. But I don't want to include it in 2.28.0 since it has already been tested via RC.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not so critical since it has workaround

Choose a reason for hiding this comment

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

what's the workaround? @neSpecc

@neSpecc neSpecc merged commit 0369ff5 into next Sep 5, 2023
6 checks passed
@neSpecc neSpecc deleted the fix/empty-array-as-blocks branch September 5, 2023 08:27
@egg- egg- mentioned this pull request Mar 29, 2024
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.

[Bug] editor.render with "blocks":[] breaks the editor
4 participants