Skip to content

Commit

Permalink
refs #1065 Scroll top when clicking the timeline title
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Aug 19, 2023
1 parent 1b07c3e commit 9340fbc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/components/timelines/Conversations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,20 @@ const Conversations: React.FC<Props> = props => {
return false
}, [firstItemIndex, conversations, setConversations, unreadConversations])

const backToTop = () => {
scrollerRef.current.scrollTo({
top: 0,
behavior: 'smooth'
})
}

return (
<div style={{ width: columnWidth(props.timeline.column_width), minWidth: columnWidth(props.timeline.column_width), margin: '0 4px' }}>
<Container style={{ height: 'calc(100% - 8px)' }}>
<Header style={{ backgroundColor: 'var(--rs-bg-card)' }}>
<FlexboxGrid align="middle" justify="space-between">
<FlexboxGrid.Item style={{ width: 'calc(100% - 80px)' }}>
<FlexboxGrid align="middle">
<FlexboxGrid align="middle" onClick={backToTop} style={{ cursor: 'pointer' }}>
{/** icon **/}
<FlexboxGrid.Item
style={{
Expand Down
9 changes: 8 additions & 1 deletion src/components/timelines/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ const Notifications: React.FC<Props> = props => {
return false
}, [firstItemIndex, notifications, setNotifications, unreadNotifications])

const backToTop = () => {
scrollerRef.current.scrollTo({
top: 0,
behavior: 'smooth'
})
}

return (
<div
style={{ width: columnWidth(props.timeline.column_width), minWidth: columnWidth(props.timeline.column_width), margin: '0 4px' }}
Expand All @@ -237,7 +244,7 @@ const Notifications: React.FC<Props> = props => {
<Header style={{ backgroundColor: 'var(--rs-bg-card)' }}>
<FlexboxGrid align="middle" justify="space-between">
<FlexboxGrid.Item style={{ width: 'calc(100% - 108px)' }}>
<FlexboxGrid align="middle">
<FlexboxGrid align="middle" onClick={backToTop} style={{ cursor: 'pointer' }}>
{/** icon **/}
<FlexboxGrid.Item
style={{
Expand Down
9 changes: 8 additions & 1 deletion src/components/timelines/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,20 @@ const Timeline: React.FC<Props> = props => {
return false
}, [firstItemIndex, statuses, setStatuses, unreadStatuses])

const backToTop = () => {
scrollerRef.current.scrollTo({
top: 0,
behavior: 'smooth'
})
}

return (
<div style={{ width: columnWidth(props.timeline.column_width), minWidth: columnWidth(props.timeline.column_width), margin: '0 4px' }}>
<Container style={{ height: '100%' }}>
<Header style={{ backgroundColor: 'var(--rs-bg-card)' }}>
<FlexboxGrid align="middle" justify="space-between">
<FlexboxGrid.Item style={{ width: 'calc(100% - 80px)' }}>
<FlexboxGrid align="middle">
<FlexboxGrid align="middle" onClick={backToTop} style={{ cursor: 'pointer' }}>
{/** icon **/}
<FlexboxGrid.Item
style={{
Expand Down

0 comments on commit 9340fbc

Please sign in to comment.