Skip to content

Commit 7c13657

Browse files
committed
fix: enable editing on AEM for dynamic container components
Fire event once component model has been fetched and rendered, to reload editables and enable editing within AEM
1 parent 6a546e9 commit 7c13657

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Constants.ts

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export class Constants {
4242
public static readonly _PAGE_CLASS_NAMES = 'aem-page';
4343
public static readonly _RESPONSIVE_GRID_PLACEHOLDER_CLASS_NAMES = 'aem-Grid-newComponent';
4444

45+
/**
46+
* Event which indicates that content of remote component has been fetched and loaded in the app
47+
*/
48+
public static readonly REMOTE_CONTENT_LOADED = 'cq-remotecontent-loaded';
49+
4550
/**
4651
* Selector for WCM mode state meta property.
4752
*/

src/components/ModelProvider.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import { Model, ModelManager } from '@adobe/aem-spa-page-model-manager';
13+
import { Model, ModelManager, PathUtils } from '@adobe/aem-spa-page-model-manager';
1414
import React, { Component } from 'react';
1515
import isEqual from 'react-fast-compare';
16+
import { Constants } from '../Constants';
1617
import { MappedComponentProperties, ReloadForceAble } from '../ComponentMapping';
1718
import Utils from '../Utils';
1819

@@ -88,6 +89,11 @@ export class ModelProvider extends Component<ModelProviderType> {
8889
const props = Utils.modelToProps(data);
8990

9091
this.setState(props);
92+
93+
// Fire event once component model has been fetched and rendered to enable editing on AEM
94+
if (injectPropsOnInit) {
95+
PathUtils.dispatchGlobalCustomEvent(Constants.REMOTE_CONTENT_LOADED, {});
96+
}
9197
}
9298
}).catch((error) => {
9399
console.log(error);

0 commit comments

Comments
 (0)