From 518c7e0a5112fa0d90cb6a9d7a403c28ffe4c6e6 Mon Sep 17 00:00:00 2001 From: Dundercover Date: Thu, 15 Nov 2018 17:06:59 +0100 Subject: [PATCH] Fix `renderBlockButton` of rich text example (#2412) By checking if there are blocks in the selection --- examples/rich-text/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/rich-text/index.js b/examples/rich-text/index.js index c3db889c7..4469b83c8 100644 --- a/examples/rich-text/index.js +++ b/examples/rich-text/index.js @@ -144,9 +144,12 @@ class RichTextExample extends React.Component { let isActive = this.hasBlock(type) if (['numbered-list', 'bulleted-list'].includes(type)) { - const { value } = this.state - const parent = value.document.getParent(value.blocks.first().key) - isActive = this.hasBlock('list-item') && parent && parent.type === type + const { value: { document, blocks } } = this.state + + if (blocks.size > 0) { + const parent = document.getParent(blocks.first().key) + isActive = this.hasBlock('list-item') && parent && parent.type === type + } } return (