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

Show all diff when uncollapse #71792

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function PseudoHtmlDiff({
reactComponentDiffLines.forEach((line, index) => {
let trimmedLine = line.trim()
const isDiffLine = trimmedLine[0] === '+' || trimmedLine[0] === '-'
const spaces = ' '.repeat(componentStacks.length * 2)
const spaces = ' '.repeat(Math.max(componentStacks.length * 2, 1))

if (isDiffLine) {
const sign = trimmedLine[0]
Expand Down Expand Up @@ -126,6 +126,15 @@ export function PseudoHtmlDiff({
</span>
)
}
} else if (!isHtmlCollapsed) {
// In general, if it's not collapsed, show the whole diff
componentStacks.push(
<span key={'comp-diff' + index}>
{spaces}
{trimmedLine}
{'\n'}
</span>
)
}
})
return componentStacks.concat(diffHtmlStack)
Expand Down
3 changes: 2 additions & 1 deletion test/development/acceptance-app/hydration-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ describe('Error overlay for hydration errors in App router', () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(1)

const pseudoHtml = await session.getRedboxComponentStack()
expect(pseudoHtml).toMatchInlineSnapshot(`"-className="server-html""`)
expect(pseudoHtml).toMatchInlineSnapshot(`"- className="server-html""`)

expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
`"Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used"`
Expand Down Expand Up @@ -960,6 +960,7 @@ describe('Error overlay for hydration errors in App router', () => {
<Mismatch>
<p>
<span>
...
+ client
- server"
`)
Expand Down
1 change: 1 addition & 0 deletions test/development/acceptance/hydration-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
<Mismatch>
<p>
<span>
...
Copy link
Member

Choose a reason for hiding this comment

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

Sweet. Looks like this matches the Turbopack snapshot now which makes me wonder how this ever worked for Turbopack but not Webpack?

+ client
- server"
`)
Expand Down
Loading