Expand my Community achievements bar.

SOLVED

Activate edit mode in component after save.

Avatar

Level 3

Hi everyone,

 

I am writing to asking whether is it possible to check and enable edit more after clicking "save" in component editing.

 

Background:

I have asked a question about editing is disable after save the component modification. However, I find that the page may switch to the preview mode after save the component editing. The condition can be fixed after I change to Preview mode then switching back to Edit mode.

 

Problem:

1. Is it possible to check the current mode and switch to edit mode after clicking the save in component modification ? 
2. Where can I catch ( or find ) the code or event about click save in component editing window ?

 

Thank you for helping.

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @TrifaCh 

 

Ideally, there should be no impact on the Edit mode of component. When we save a component, the page is still in Edit mode and thus the components.

 

  • Can you please check, if you have any cq:listeners configured which might be impacting?
  • If no, can you please configure a cq:listener and if it helps? They come with various triggers and intended beahviours, like:
    • REFRESH_SELF
    • REFRESH_PARENT
    • REFRESH_PAGE
    • REFRESH_INSERTED

http://www.sgaemsolutions.com/2019/01/ootbcustom-cqlisteners-in-cqeditconfig.html


Aanchal Sikka

View solution in original post

12 Replies

Avatar

Community Advisor

Hello @TrifaCh,

 

Though I am not sure about the business that you want to achieve, but its seems you want to maintain consistency of the configurable properties within the component dialog. If that is the case, I think you can achieve it with design dialog

 

For your reference: 

https://experienceleague.adobe.com/docs/experience-manager-65/developing/components/developing-compo...

 

http://www.aemcq5tutorials.com/tutorials/create-design-dialog-in-aem/

 

If you can share some more detail on the business ask, probably will be able to help more..

 

Thanks

 

  

Avatar

Level 3

Thank you for answer. I think my problem should go deeper to the self-defined AEM component. Should define some event handling in component save, delete, edit and so on.

Avatar

Community Advisor

Hi @TrifaCh 
Can you check if you are using any cq:listerner EditConfig in your component. By default the mode does not changed

edit-component.gif

 

 

 

You can look for cookie to find out the correct mode

arunpatidar_0-1695197169162.png

 



Arun Patidar

Avatar

Level 3

Thank you for answer. The Value of cq-editor, cq-authoring and wcmmode is not change. However, it likes enter the Perview mode.

Avatar

Correct answer by
Community Advisor

Hello @TrifaCh 

 

Ideally, there should be no impact on the Edit mode of component. When we save a component, the page is still in Edit mode and thus the components.

 

  • Can you please check, if you have any cq:listeners configured which might be impacting?
  • If no, can you please configure a cq:listener and if it helps? They come with various triggers and intended beahviours, like:
    • REFRESH_SELF
    • REFRESH_PARENT
    • REFRESH_PAGE
    • REFRESH_INSERTED

http://www.sgaemsolutions.com/2019/01/ootbcustom-cqlisteners-in-cqeditconfig.html


Aanchal Sikka

Avatar

Level 3

Thank you very much. I will try to use your method to solve the problem first.

Avatar

Administrator

@TrifaCh Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 3

Some suggestion is helpful. But I still find the solution of my problem. I will share it after finding it. Thanks.

Avatar

Level 3

Figure 1. The Elements in edit mode.

Screenshot 2023-09-21 at 3.43.11 PM.png

Figure 2. The Elements after clicking save and page refresh (Should be save as Preview mode)

Screenshot 2023-09-21 at 11.08.08 AM.png

  

Hi everyone, I just found something about the problem. As showing in Figure 1, there should be a Editable div tag in the Edit mode. However, the Element turn to Figure 2 after page fresh.(The clicking in save button in component window trigger the event) The Editable div tag is missed.

 

That is reason why the system back to normal after switching to Preview and back to Edit mode.

Avatar

Community Advisor

@TrifaCh 

 

Can you please check if you are using the placeholder div properly? Also, assure isEmpty is properly resolved

 

Example in text component, observe the placeholder <sly>

 

<div data-sly-use.textModel="com.adobe.cq.wcm.core.components.models.Text"
     data-sly-use.component="com.adobe.cq.wcm.core.components.models.Component"
     data-sly-use.templates="core/wcm/components/commons/v1/templates.html"
     data-sly-test.text="${textModel.text}"
     data-cmp-data-layer="${textModel.data.json}"
     id="${component.id}"
     class="cmp-text">
    <p class="cmp-text__paragraph"
       data-sly-unwrap="${textModel.isRichText}">${text @ context = textModel.isRichText ? 'html' : 'text'}</p>
</div>
<sly data-sly-call="${templates.placeholder @ isEmpty = !text, classAppend='cmp-text'}"></sly>

 

which in turn uses /libs/core/wcm/components/commons/v1/templates.html

 

 

<sly data-sly-template.placeholder="${@ isEmpty, classAppend, emptyTextAppend}">
    <div data-sly-test="${(wcmmode.edit || wcmmode.preview) && isEmpty}"
         class="cq-placeholder ${classAppend}"
         data-emptytext="${component.properties.jcr:title}${emptyTextAppend && ' - '}${emptyTextAppend}"></div>
</sly>

 

 


Aanchal Sikka

Avatar

Level 3

No, there is no any sly tag in my Element tab. Thank you for answer.

Avatar

Level 3

After making comparison, I think I may need a method to force reload the edit mode in code. All configurations are in Edit mode, but the Element is in Preview mode.