Skip to content

Commit

Permalink
Remove the bottom collapse button in dev overlay (#71658)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Oct 23, 2024
1 parent dca6516 commit 54768ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,18 @@ export function RuntimeError({ error }: RuntimeErrorProps) {
}
}, [error.frames])

const [all, setAll] = React.useState(firstFrame == null)

const {
canShowMore,
leadingFramesGroupedByFramework,
stackFramesGroupedByFramework,
} = React.useMemo(() => {
const leadingFrames = allLeadingFrames.filter((f) => f.expanded || all)
const visibleCallStackFrames = allCallStackFrames.filter(
(f) => f.expanded || all
)

return {
canShowMore:
allCallStackFrames.length !== visibleCallStackFrames.length ||
(all && firstFrame != null),

stackFramesGroupedByFramework:
groupStackFramesByFramework(allCallStackFrames),

leadingFramesGroupedByFramework:
groupStackFramesByFramework(leadingFrames),
}
}, [all, allCallStackFrames, allLeadingFrames, firstFrame])
const { leadingFramesGroupedByFramework, stackFramesGroupedByFramework } =
React.useMemo(() => {
const leadingFrames = allLeadingFrames.filter((f) => f.expanded)

return {
stackFramesGroupedByFramework:
groupStackFramesByFramework(allCallStackFrames),

leadingFramesGroupedByFramework:
groupStackFramesByFramework(leadingFrames),
}
}, [allCallStackFrames, allLeadingFrames])

return (
<React.Fragment>
Expand All @@ -82,32 +70,11 @@ export function RuntimeError({ error }: RuntimeErrorProps) {
/>
</React.Fragment>
) : undefined}
{canShowMore ? (
<React.Fragment>
<button
tabIndex={10}
data-nextjs-data-runtime-error-collapsed-action
type="button"
onClick={() => setAll(!all)}
>
{all ? 'Hide' : 'Show'} collapsed frames
</button>
</React.Fragment>
) : undefined}
</React.Fragment>
)
}

export const styles = css`
button[data-nextjs-data-runtime-error-collapsed-action] {
background: none;
border: none;
padding: 0;
font-size: var(--size-font-small);
line-height: var(--size-font-bigger);
color: var(--color-accents-3);
}
[data-nextjs-call-stack-frame]:not(:last-child),
[data-nextjs-component-stack-frame]:not(:last-child) {
margin-bottom: var(--size-gap-double);
Expand Down
24 changes: 0 additions & 24 deletions test/development/acceptance-app/ReactRefreshLogBox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,12 +803,6 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
expect(source).toContain('app/page.js')
expect(source).toContain(`throw new Error('Client error')`)

await expect(
browser.hasElementByCssSelector(
'[data-nextjs-data-runtime-error-collapsed-action]'
)
).resolves.toEqual(false)

const stackFrameElements = await browser.elementsByCss(
'[data-nextjs-call-stack-frame]'
)
Expand Down Expand Up @@ -844,12 +838,6 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
expect(source).toContain('app/page.js')
expect(source).toContain(`throw new Error('Server error')`)

await expect(
browser.hasElementByCssSelector(
'[data-nextjs-data-runtime-error-collapsed-action]'
)
).resolves.toEqual(false)

const stackFrameElements = await browser.elementsByCss(
'[data-nextjs-call-stack-frame]'
)
Expand Down Expand Up @@ -893,12 +881,6 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`throw new Error("This is an error from an anonymous function")`
)

await expect(
browser.hasElementByCssSelector(
'[data-nextjs-data-runtime-error-collapsed-action]'
)
).resolves.toEqual(false)

const stackFrameElements = await browser.elementsByCss(
'[data-nextjs-call-stack-frame]'
)
Expand Down Expand Up @@ -963,12 +945,6 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
expect(source).toContain('app/page.js')
expect(source).toContain(`new URL("/", "invalid")`)

await expect(
browser.hasElementByCssSelector(
'[data-nextjs-data-runtime-error-collapsed-action]'
)
).resolves.toEqual(false)

const stackFrameElements = await browser.elementsByCss(
'[data-nextjs-call-stack-frame]'
)
Expand Down

0 comments on commit 54768ac

Please sign in to comment.