Issue #2958Opened August 13, 2020by rudym870 reactions

BUG: editor.Panels.removeButton('options', 'preview') breaks View code

Question

Version: 0.16.18

Are you able to reproduce the bug from the demo? No

What is the expected behavior? I want to hide the default preview button while keeping the default "View code" button.

What is the current behavior? "View code" no longer works if the preview button is removed via

editor.Panels.removeButton('options', 'preview')

Are you able to attach screenshots, screencasts or a live demo?

Yes: JS Fiddle

Answers (2)

mcottretAugust 27, 20200 reactions

Hi @rudym87 !

The problem seems to be caused by the deactivation of the button clicked to run the command (cf below), which causes the modal to instantly close.

https://github.com/artf/grapesjs/blob/a85126883fbeafe3a437b1421b952931a5aaafc0/src/commands/view/ExportTemplate.js#L5-L7

I have no idea why it only happens when the preview button has been removed, still it seems wierd to me to deactivate it while the code modal is still opened. I think it should rather be stored & disabled once the modal is closed (on stop), that way the button would stay active while the modal is open as shown in the following screenshot:

<img width="703" alt="Screenshot 2020-08-27 at 3 16 24 PM" src="https://user-images.githubusercontent.com/9916749/91451010-3e2e5000-e87d-11ea-8afa-62ca0bf99cdc.png">

This fixes the aforementioned problem, & is also visually more coherent in my opinion. @artf what do you think ? As always, I'd be happy to open a PR for this :) !

Cheers !

artfAugust 28, 20200 reactions

correct @mcottret, honestly, I don't even see the reason anymore to keep this command stateful. So, I'd remove that useless sender.set('active', 0) and the stop function from it. Let me know if you have a better idea

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.