Skip to content

Commit

Permalink
Show all diff when uncollapse (#71792)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Oct 24, 2024
1 parent eabfdea commit a8de873
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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>
...
+ client
- server"
`)
Expand Down

0 comments on commit a8de873

Please sign in to comment.