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

Fix bug (#141) XP editor for react requires save and refresh before adding new renderings #343

Conversation

vsirakova
Copy link
Contributor

@vsirakova vsirakova commented Mar 12, 2020

Fixes issue #141: when working in XP editor in the react version, after adding a rendering with a placeholder, another rendering cannot be added in the freshly loaded placeholder but save and refresh of the page is required

Description

The issue is caused by the fact that the very important key attribute of the <code> DOM element that represents the placeholder is missing after SSR. Because it is a react special prop it cannot be set directly as a prop and then transferred as an attribute and that's why in the sitecore jss library for react this problem is solved by adding the key attribute by directly modifying the DOM on the client side. But after a rendering is freshly added through SSR, it is not hydrated and the lifecycle methods are not running, so the key attribute is never added.
The fix replaces phkey attribute with key attribute directly in the html that is about to be sent to XP editor to inject.

Motivation

It is quite annoying to have to save your page on each step if you want to add renderings within other renderings. It is much faster and smoother to be able to add multiple renderings in one go.

Fixes issue #141

How Has This Been Tested?

Tested manually on my local environment

Types of changes

  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the Contributing guide.
  • [ x] My code follows the code style of this project.
  • My change requires a change to the documentation.

…before adding new renderings into freshly rendered placeholders
@sc-illiakovalenko
Copy link
Contributor

sc-illiakovalenko commented May 20, 2020

@vsirakova Thank you very much, good catch. 👍
I tested, it's working as expected.

@aweber1
Copy link
Contributor

aweber1 commented May 20, 2020

I would suggest noting this issue and resolution in documentation somewhere because the fix is at the app level and not the React package level. Therefore, anyone that is not using the JSS sample app as a basis will still encounter this issue.

@sc-illiakovalenko
Copy link
Contributor

sc-illiakovalenko commented May 20, 2020

@aweber1 I will mention this issue.
Can I add section "Troubleshooting" in
https://jss.sitecore.com/docs/client-frameworks/react/sample-app
at the end? Or is it enough to add it to release notes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants