mirror of https://github.com/artf/grapesjs.git
Browse Source
As described by [this issue](artf/grapesjs#2637), the component borders may not be toggled back when exiting preview mode in some cases. This fixes this issue by adding a `shouldRunSwVisibility` flag to the Preview command, set via the Commands API on its run (before stopping the `sw-visibility` command if it's active), & used on stop to reactivate the `sw-visibility` command if needed. Which also implies: - Prevent toggling of component borders while preview is active - Rely on the Commands API to detect if the `sw-visibility` command is active rather than a panel button - Prevent resetting the `shouldRunVisibility` flag on multiple subsequent (forced) runs / stops of the preview commandpull/2689/head
4 changed files with 79 additions and 18 deletions
@ -0,0 +1,29 @@ |
|||
import SwitchVisibility from '../../../../src/commands/view/SwitchVisibility'; |
|||
|
|||
describe('SwitchVisibility command', () => { |
|||
let fakeEditor, fakeFrames, fakeIsActive; |
|||
|
|||
beforeEach(() => { |
|||
fakeFrames = []; |
|||
fakeIsActive = false; |
|||
|
|||
fakeEditor = { |
|||
Canvas: { |
|||
getFrames: jest.fn(() => fakeFrames) |
|||
}, |
|||
|
|||
Commands: { |
|||
isActive: jest.fn(() => fakeIsActive) |
|||
} |
|||
}; |
|||
}); |
|||
|
|||
describe('.toggleVis', () => { |
|||
it('should do nothing if the preview command is active', () => { |
|||
expect(fakeEditor.Canvas.getFrames).not.toHaveBeenCalled(); |
|||
fakeIsActive = true; |
|||
SwitchVisibility.toggleVis(fakeEditor); |
|||
expect(fakeEditor.Canvas.getFrames).not.toHaveBeenCalled(); |
|||
}); |
|||
}); |
|||
}); |
|||
Loading…
Reference in new issue