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

🐛 BUG: Ternary expressions in slot erase everything else #955

Closed
tamaracha opened this issue Feb 1, 2024 · 2 comments · Fixed by #963
Closed

🐛 BUG: Ternary expressions in slot erase everything else #955

tamaracha opened this issue Feb 1, 2024 · 2 comments · Fixed by #963
Assignees
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)

Comments

@tamaracha
Copy link

What version of @astrojs/compiler are you using?

2.5.2

What package manager are you using?

npm

What operating system are you using?

Mac OS Ventura 13.6.1

Describe the Bug

If a slot, e.g., a layout's default slot, contains multiple elements and if one of them is a jsx ternary expression, only this one remains and the other ones disappear. It looks similar to #950, but with ternary instead of loops.

Everything before and after this within a slot will be erased:

{isLeaf ? <p>Leaf</p> : <p>Branch</p>}

Moving the expression into a fragment solves the problem:

<>
  {isLeaf ? <p>Leaf</p> : <p>Branch</p>}
</>

Is this intended?

My reprex is the astro blog template with the critical addition in the BlogPost layout.

Link to Minimal Reproducible Example

https://github.com/tamaracha/reprex-astro-syntax

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 1, 2024
@MoustaphaDev
Copy link
Member

Thanks for reporting the issue! This seems like regression that snuck in with the last patch. I'll dig into this further to get a fix ASAP.

@MoustaphaDev MoustaphaDev added the - P3: minor bug An edge case that only affects very specific usage (priority) label Feb 2, 2024
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Feb 2, 2024
@MoustaphaDev MoustaphaDev self-assigned this Feb 2, 2024
@natemoo-re natemoo-re added - P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority) and removed - P3: minor bug An edge case that only affects very specific usage (priority) labels Feb 2, 2024
@natemoo-re natemoo-re assigned natemoo-re and unassigned MoustaphaDev Feb 2, 2024
natemoo-re added a commit that referenced this issue Feb 3, 2024
@ferencalmasi
Copy link

A similar issue is happening with fragments. It might be related to this. Link to issue: withastro/astro#9997

Princesseuh pushed a commit that referenced this issue Feb 6, 2024
…" (#963)

* test(#955): add failing test

* test(#955): add another failing test

* test: whoops it actually passes

* Revert "Fix slot regression when there are multiple expressions (#952)"

This reverts commit 418558c.

* Revert "Fix various issues with slots (#933)"

This reverts commit db13db9.

* chore: changeset

* chore: remove slot parens in test

* test: update test

* chore: remove slot parens in test

* test: add test for #959

---------

Co-authored-by: Nate Moore <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P5: urgent Fix build-breaking bugs affecting most users, should be released ASAP (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants