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

[sitecore-jss-react] [sitecore-jss-nextjs] Default Placeholder Content for empty fields in editMode metadata #1831

Merged
merged 25 commits into from
Jul 8, 2024

Conversation

yavorsk
Copy link
Contributor

@yavorsk yavorsk commented Jun 24, 2024

Description / Motivation

This PR enhances the rendering of fields in editing mode for editMode metadata. When a field value is empty, a placeholder content should be rendered to signify that the field has no value. The placeholder should be interactable, so user can add value to the field. Additionally developers can provide their own custom empty field placeholder component via the field's emptyValueEditingPlaceholder prop, which will be rendered instead of the default one.
The fields with this functionality are:

  • [sitecore-jss-react] Date.tsx
  • [sitecore-jss-react] Image.tsx
  • [sitecore-jss-react] Link.tsx
  • [sitecore-jss-react] RichText.tsx
  • [sitecore-jss-react] Text.tsx
  • [sitecore-jss-nextjs] Link.tsx
  • [sitecore-jss-nextjs] NextImage.tsx
  • [sitecore-jss-nextjs] RichText.tsx

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate): Test in XmCloud in editMode=metadata

Types of changes

  • 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)

@yavorsk yavorsk requested review from a team and ambrauer June 24, 2024 13:53
Copy link
Contributor

@art-alexeyenko art-alexeyenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid work, thank you!
Let's refine it a bit

packages/sitecore-jss/src/layout/utils.ts Outdated Show resolved Hide resolved
packages/sitecore-jss/src/layout/utils.ts Outdated Show resolved Hide resolved
}

return true;
} else if (typeof fieldValue === 'number') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (typeof fieldValue === 'number') {
} else if (typeof fieldValue === 'number') {
// Avoid returning true for 0

expect(rendered.html()).to.equal(expected.html());
});

it('Should render custom empty value placeholder if provided via props if field value is empty in metadata edit mode', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('Should render custom empty value placeholder if provided via props if field value is empty in metadata edit mode', () => {
it('Should render custom empty component if provided via props if field value is empty in metadata edit mode', () => {

Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
See some other comments below
Also, revisit comments:
1- #1831 (comment)
2- #1831 (comment)

Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@yavorsk yavorsk merged commit b4309e8 into dev Jul 8, 2024
1 check passed
@yavorsk yavorsk deleted the feature/JSS-3455 branch July 8, 2024 11:58
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.

5 participants