Skip to content

Commit

Permalink
[v3] fix RangeError: Maximum call stack size exceeded in `findSumma…
Browse files Browse the repository at this point in the history
…ry` when `child.props.children` is `undefined` (#3046)

* aa

* aa
  • Loading branch information
Dimitri POSTOLOV committed Jul 22, 2024
1 parent d387dad commit 363b85f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .changeset/small-ads-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'nextra-theme-blog': patch
'nextra-theme-docs': patch
'nextra': patch
---

add `flex-shrink: 0` for indent in `FileTree` for `<Ident />` and svg icons in `<Folder />`
and `<File />`
6 changes: 6 additions & 0 deletions .changeset/warm-mice-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'nextra-theme-docs': patch
---

fix `RangeError: Maximum call stack size exceeded` in `findSummary` when `child.props.children`
is `undefined`
2 changes: 1 addition & 1 deletion packages/nextra-theme-docs/src/mdx-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Details({
})
return
}
if (child.type !== Details) {
if (child.type !== Details && child.props.children) {
;[summary, child] = findSummary(child.props.children)
}
}
Expand Down
19 changes: 16 additions & 3 deletions packages/nextra/src/client/components/file-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function Ident(): ReactElement {
return (
<>
{Array.from({ length }, (_, i) => (
<span className="_w-5" key={i} />
// Text can shrink indent
<span className="_w-5 _shrink-0" key={i} />
))}
</>
)
Expand All @@ -69,7 +70,13 @@ const Folder = memo<FolderProps>(
className="_inline-flex _cursor-pointer _items-center _py-1 hover:_opacity-60"
>
<Ident />
<svg width="1em" height="1em" viewBox="0 0 24 24">
<svg
width="1em"
height="1em"
viewBox="0 0 24 24"
// Text can shrink icon
className="_shrink-0"
>
<path
fill="none"
stroke="currentColor"
Expand Down Expand Up @@ -105,7 +112,13 @@ const File = memo<FileProps>(({ label, name, active }) => (
>
<span className="_inline-flex _cursor-default _items-center _py-1">
<Ident />
<svg width="1em" height="1em" viewBox="0 0 24 24">
<svg
width="1em"
height="1em"
viewBox="0 0 24 24"
// Text can shrink icon
className="_shrink-0"
>
<path
fill="none"
stroke="currentColor"
Expand Down

0 comments on commit 363b85f

Please sign in to comment.