[MGNLFE-45] Incorrect behaviour in inEditor() helper Created: 04/May/20  Updated: 19/May/20  Resolved: 19/May/20

Status: Closed
Project: Magnolia Frontend Helpers
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0.2

Type: Bug Priority: Critical
Reporter: Christopher Zimmermann Assignee: Canh Nguyen
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 2d 7h
Original Estimate: Not Specified

Attachments: PNG File preview-with-green-bars.png    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: SPA Editor
Sprint: HL & LD 2
Story Points: 3

 Description   

inEditor() should only return true when in the actual editing view.
inEditorPreview() should  true when in the preview mode (Same behavirour as it has now)

It is consistant cmsfn, it is more natural for developers to use in their apps, and it will fix the problem that the greenbars are rendered in the Page Editor Preview.

Notes

The helper functions exposed in react-editor and angular-editor, inEditor() and inEditorPreview() should peform the same function to our our freemarker templating functions cmsfn.
cmsfn.inEditMode()
cmsfn.inPreviewMode()
https://documentation.magnolia-cms.com/display/DOCS61/cmsfn#cmsfn-Checkforeditmode

But the behaviour is different.
In cmsfn, inEditMode() only returns true if you are in the PageEditor edit view, NOT if you are in the preview view. 
As far as usage in the React and Angular apps - the most common question is “Am I in the actual page editor?” to know whether to call templateDefinitions endpoint or not. Now it is strange because I have to do something like

if (EditorContextHelper.inEditor && !EditorContextHelper.inEditorPreview(){
 //call templateDefinitions
}

 

 

Acceptance Criteria

  • Ensure that green bars are not displayed in the Preview (as described below.)
     

 

Previous ticket description:

Preview in Admincentral shows green bars in React in 1.0.1

With react-editor 1.0.1, the adminCentral Preview also renders 'green bars', but it should not.

Note, this only happens if an Area is selected in the pageEditor, and then you switch to the Preview.
If no Areas are selected, then no green bars are rendered in the preview.

Potential root causes:

1. EmbeddableArea now calls the refresh() command:

https://git.magnolia-cms.com/projects/MODULES/repos/frontend-helpers/browse/packages/react-editor/src/component/EditableArea/EditableArea.js#29

I'm not sure why the area needs to call the refresh() command, I would think that it is up to the app itself to make these calls.

2. Currently any call to the mgnlRefresh() function must first check if the page is in Preview mode, because the inEditor() command returns true whether in preview mode or not. (see attached image)

 

 

 


Generated at Mon Feb 12 05:43:42 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.