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: able to edit and preview when we have no content #3726

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sidmohanty11
Copy link
Contributor

@sidmohanty11 sidmohanty11 commented Nov 7, 2024

Description

Jira
https://builder-io.atlassian.net/browse/PLAN-338

Screenshot
If relevant, add a screenshot or two of the changes you made.

Copy link

changeset-bot bot commented Nov 7, 2024

⚠️ No Changeset found

Latest commit: d95b383

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

style={{
display:
!props.builderContextSignal.value.content &&
(isPreviewing() || isEditing())
Copy link
Collaborator

@teleaziz teleaziz Nov 13, 2024

Choose a reason for hiding this comment

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

should this be?

style={(isEditing() || isPreviewing() || props.builderContextSignal.value.content) 
 ? {} 
 : { display: 'none' }}

Copy link
Contributor

Choose a reason for hiding this comment

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

because we have custom event listeners on the div ref that enable visual editing, we want to visually hide this wrapper div in editing/preview if content is empty, but still render it. if we don't hide it it might break customer layouts because it'll be an empty div with no content.

so:

  • content exists: render div and display: undefined
  • content does not exist but isEditing/isPreviewing: render div and display: 'none'
    • once inline editing kicks in, it will populate the content and re-render, so display style will be removed

your suggestion would display this div in the second case even if we never get content, which we want to avoid.

Copy link
Contributor

Choose a reason for hiding this comment

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

having said all of that, this logic has a lot of booleans so it would be good to summarize the thought behind it in a comment @sidmohanty11

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.

3 participants