Unverified Commit a8de8730 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Show all diff when uncollapse (#71792)

parent eabfdea2
...@@ -85,7 +85,7 @@ export function PseudoHtmlDiff({ ...@@ -85,7 +85,7 @@ export function PseudoHtmlDiff({
reactComponentDiffLines.forEach((line, index) => { reactComponentDiffLines.forEach((line, index) => {
let trimmedLine = line.trim() let trimmedLine = line.trim()
const isDiffLine = trimmedLine[0] === '+' || trimmedLine[0] === '-' const isDiffLine = trimmedLine[0] === '+' || trimmedLine[0] === '-'
const spaces = ' '.repeat(componentStacks.length * 2) const spaces = ' '.repeat(Math.max(componentStacks.length * 2, 1))
if (isDiffLine) { if (isDiffLine) {
const sign = trimmedLine[0] const sign = trimmedLine[0]
...@@ -126,6 +126,15 @@ export function PseudoHtmlDiff({ ...@@ -126,6 +126,15 @@ export function PseudoHtmlDiff({
</span> </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) return componentStacks.concat(diffHtmlStack)
......
...@@ -212,7 +212,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -212,7 +212,7 @@ describe('Error overlay for hydration errors in App router', () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(1) expect(await getRedboxTotalErrorCount(browser)).toBe(1)
const pseudoHtml = await session.getRedboxComponentStack() const pseudoHtml = await session.getRedboxComponentStack()
expect(pseudoHtml).toMatchInlineSnapshot(`"-className="server-html""`) expect(pseudoHtml).toMatchInlineSnapshot(`"- className="server-html""`)
expect(await session.getRedboxDescription()).toMatchInlineSnapshot( 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"` `"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"`
...@@ -960,6 +960,7 @@ describe('Error overlay for hydration errors in App router', () => { ...@@ -960,6 +960,7 @@ describe('Error overlay for hydration errors in App router', () => {
<Mismatch> <Mismatch>
<p> <p>
<span> <span>
...
+ client + client
- server" - server"
`) `)
......
...@@ -1277,6 +1277,7 @@ describe('Error overlay for hydration errors in Pages router', () => { ...@@ -1277,6 +1277,7 @@ describe('Error overlay for hydration errors in Pages router', () => {
<Mismatch> <Mismatch>
<p> <p>
<span> <span>
...
+ client + client
- server" - server"
`) `)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment