Sitecore / jss

Software development kit for JavaScript developers building web applications with Sitecore Experience Platform
https://jss.sitecore.com
Apache License 2.0
263 stars 275 forks source link

[sitecore-jss-react] [sitecore-jss-nextjs] Add support for chrome's hydration for fields #1773

Closed yavorsk closed 7 months ago

yavorsk commented 7 months ago

Description / Motivation

This PR introduces FieldMetadata component and functionality to render it when metadata field property is provided in the field's layout data. In such case the field component is wrapped with metadata markup to enable chromes hydration when editing in pages. Ability to render metadata has been added to the following field components:

Testing Details

Types of changes

illiakovalenko commented 7 months ago

@yavorsk I'm still struggling regarding adding forwardRef for all the components, even if they are not using ref. Regarding type definition - it's a breaking change, I think Especially in a old React docs, it's mentioned as well: https://legacy.reactjs.org/docs/forwarding-refs.html#note-for-component-library-maintainers Still we might need to think how to workaround this problem using an elegant approach.