Skip to content

Commit 549e540

Browse files
committed
Remove Scroller from TreeNode
1 parent ef94217 commit 549e540

File tree

1 file changed

+9
-33
lines changed

1 file changed

+9
-33
lines changed

theme/src/components/TreeNode.tsx

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import React from 'react'
2-
import { Item, Info } from '../types'
3-
import { firstUrl } from '../util/tree'
41
import {
5-
useTheme,
6-
Theme,
7-
List,
2+
Collapse,
83
Icons,
4+
List,
95
ListItem,
106
ListItemText,
11-
Collapse
7+
Theme,
8+
useTheme
129
} from '@committed/components'
10+
import React from 'react'
11+
import { Info, Item } from '../types'
12+
import { firstUrl } from '../util/tree'
1313

1414
export interface TreeNodeProps extends Item {
1515
isActive: (id: string) => boolean
@@ -21,30 +21,6 @@ export interface TreeNodeProps extends Item {
2121
id: string
2222
}
2323

24-
class Scroller extends React.Component<{ active: boolean }> {
25-
private ref = React.createRef<HTMLDivElement>()
26-
27-
scroll = () => {
28-
const { active } = this.props
29-
30-
if (active) {
31-
this.ref.current.scrollIntoView({ block: 'center', inline: 'nearest' })
32-
}
33-
}
34-
35-
componentDidMount() {
36-
this.scroll()
37-
}
38-
39-
componentDidUpdate() {
40-
this.scroll()
41-
}
42-
43-
render() {
44-
return <div ref={this.ref}>{this.props.children}</div>
45-
}
46-
}
47-
4824
export const TreeNode = React.memo(
4925
({
5026
id,
@@ -65,7 +41,7 @@ export const TreeNode = React.memo(
6541
const title = info ? info.title : label
6642
const active = isActive(id)
6743
return (
68-
<Scroller active={active}>
44+
<>
6945
<ListItem
7046
style={{
7147
paddingLeft: theme.spacing(2) * (level + 1)
@@ -111,7 +87,7 @@ export const TreeNode = React.memo(
11187
</List>
11288
</Collapse>
11389
) : null}
114-
</Scroller>
90+
</>
11591
)
11692
}
11793
)

0 commit comments

Comments
 (0)