Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vue][Horizon] Cannot add a new rendering or highlight existing #895

Merged
merged 4 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function renderView(callback, path, data, viewBag) {
// or else you're vulnerable to XSS.
let html = indexTemplate;
// write the Vue app
html = assertReplace(html, '<div id="root"></div>', `${renderedApp}`);
html = assertReplace(html, '<div id="root"></div>', `<div id="root">${renderedApp}</div>`);
// write the string version of our state
html = assertReplace(
html,
Expand Down
10 changes: 4 additions & 6 deletions packages/create-sitecore-jss/src/templates/vue/src/AppRoot.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<!--
-->
<template>
<div id="root">
<context-view :visible="contextViewVisible" />
<!-- 'router-view' is a "global" component that is injected into the Vue component registry by vue-router. -->
<router-view />
<div v-if="languageIsChanging" class="alert alert-info">Language is changing...</div>
</div>
<context-view :visible="contextViewVisible" />
<!-- 'router-view' is a "global" component that is injected into the Vue component registry by vue-router. -->
<router-view />
<div v-if="languageIsChanging" class="alert alert-info">Language is changing...</div>
</template>

<script>
Expand Down
14 changes: 8 additions & 6 deletions packages/sitecore-jss-vue/src/components/PlaceholderCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Item,
RouteData,
} from '@sitecore-jss/sitecore-jss/layout';
import { HorizonEditor, resetEditorChromes } from '@sitecore-jss/sitecore-jss/utils';
import { Component, h, VNode, DefineComponent, ref, watchEffect } from 'vue';
import { MissingComponent } from './MissingComponent';
import { HiddenRendering, HIDDEN_RENDERING_NAME } from './HiddenRendering';
Expand Down Expand Up @@ -211,12 +212,13 @@ function createRawElement(elem: any) {
elem.attributes.chrometype === 'placeholder' &&
elem.attributes.key
) {
watchEffect(
() => {
elRef.value.setAttribute('key', elem.attributes.key);
},
{ flush: 'post' }
);
watchEffect(() => {
elRef.value && elRef.value.setAttribute('key', elem.attributes.key);

if (elRef && HorizonEditor.isActive()) {
resetEditorChromes();
}
});
}

return () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should pass properties
id="main"
class="scpm"
data-selectable="true"
key="main"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"main","expandedDisplayName":null}
</code>
Expand All @@ -265,7 +264,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should pass properties
id="page_header"
class="scpm"
data-selectable="true"
key="page-header"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"page-header","expandedDisplayName":null}
</code>
Expand Down Expand Up @@ -303,7 +301,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should pass properties
id="page_content"
class="scpm"
data-selectable="true"
key="page-content"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"page-content","expandedDisplayName":null}
</code>
Expand Down Expand Up @@ -370,7 +367,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should render a placeho
id="page_content"
class="scpm"
data-selectable="true"
key="page-content"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"page-content","expandedDisplayName":null}
</code>
Expand Down Expand Up @@ -423,7 +419,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should render component
id="main"
class="scpm"
data-selectable="true"
key="main"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"main","expandedDisplayName":null}
</code>
Expand All @@ -448,7 +443,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should render component
id="page_header"
class="scpm"
data-selectable="true"
key="page-header"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"page-header","expandedDisplayName":null}
</code>
Expand Down Expand Up @@ -486,7 +480,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should render component
id="page_content"
class="scpm"
data-selectable="true"
key="page-content"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"page-content","expandedDisplayName":null}
</code>
Expand Down Expand Up @@ -560,7 +553,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should render nested pl
id="main"
class="scpm"
data-selectable="true"
key="main"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"main","expandedDisplayName":null}
</code>
Expand All @@ -581,7 +573,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should render nested pl
id="page_header"
class="scpm"
data-selectable="true"
key="page-header"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"page-header","expandedDisplayName":null}
</code>
Expand Down Expand Up @@ -619,7 +610,6 @@ exports[`<Placeholder /> with LayoutService data - EE on should render nested pl
id="page_content"
class="scpm"
data-selectable="true"
key="page-content"
>
{"commands":[{"click":"chrome:placeholder:addControl","header":"Add to here","icon":"/temp/iconcache/office/16x16/add.png","disabledIcon":"/temp/add_disabled16x16.png","isDivider":false,"tooltip":"Add a new rendering to the '{0}' placeholder.","type":""},{"click":"chrome:placeholder:editSettings","header":"","icon":"/temp/iconcache/office/16x16/window_gear.png","disabledIcon":"/temp/window_gear_disabled16x16.png","isDivider":false,"tooltip":"Edit the placeholder settings.","type":""}],"contextItemUri":"sitecore://master/{9BCF4A17-2EC7-4160-9504-5ABD096B46AE}?lang=en&amp;ver=1","custom":{"allowedRenderings":[],"editable":"true"},"displayName":"page-content","expandedDisplayName":null}
</code>
Expand Down