BUG: editor.Panels.removeButton('options', 'preview') breaks View code
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
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:
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 !
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