From 1055019bc1741ed4e1c7134c8048693396aa2490 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 14 Apr 2020 17:47:36 -0300 Subject: [PATCH] Fix movable blocks when editor is readOnly (#315) --- src/components/MegadraftEditor.js | 27 ++++++++++++------------ tests/components/MegadraftEditor_test.js | 12 +++++++++++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/components/MegadraftEditor.js b/src/components/MegadraftEditor.js index 7a70a57b..ff0637cd 100644 --- a/src/components/MegadraftEditor.js +++ b/src/components/MegadraftEditor.js @@ -98,19 +98,20 @@ export default class MegadraftEditor extends Component { for (let [blockType, data] of DefaultDraftBlockRenderMap.entrySeq()) { r.set(blockType, { ...data, - wrapper: this.props.movableBlocks ? ( - - ) : ( - - ) + wrapper: + !this.props.readOnly && this.props.movableBlocks ? ( + + ) : ( + + ) }); } }); diff --git a/tests/components/MegadraftEditor_test.js b/tests/components/MegadraftEditor_test.js index 848ef249..7525cc78 100644 --- a/tests/components/MegadraftEditor_test.js +++ b/tests/components/MegadraftEditor_test.js @@ -838,6 +838,18 @@ describe("MegadraftEditor Component", () => { ); }; + it("should not render MoveControl when readOnly is present", () => { + const wrapper = mount( + + ); + expect(wrapper.find(".move-control").exists()).toBeFalsy(); + }); + it("with the top block by clicking the up control", () => { const expected = [ "block-kst0",