Uploaded image for project: 'Magnolia Frontend Helpers'
  1. Magnolia Frontend Helpers
  2. MGNLFE-45

Incorrect behaviour in inEditor() helper

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 1.0.2
    • None
    • None
    • None

    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)

       

       

       

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              canh.nguyen Canh Nguyen
              czimmermann Christopher Zimmermann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD

                  Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0d
                    0d
                    Logged:
                    Time Spent - 2d 7h
                    2d 7h