Skip to content

Commit b357209

Browse files
committed
fix(neuron-ui): handle overflow on recent activities
1 parent 1bd0665 commit b357209

3 files changed

Lines changed: 37 additions & 16 deletions

File tree

packages/neuron-ui/src/components/History/hooks.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
import { useState, useEffect } from 'react'
22
import { updateTransactionList } from 'states/stateProvider/actionCreators/transactions'
33
import { queryParsers } from 'utils/parser'
4-
5-
const backToTop = () => {
6-
const container = document.querySelector('main') as HTMLElement
7-
if (container) {
8-
container.scrollIntoView({
9-
behavior: 'smooth',
10-
block: 'start',
11-
inline: 'nearest',
12-
})
13-
}
14-
}
4+
import { backToTop } from 'utils/animations'
155

166
export const useSearch = (search: string = '', walletID: string = '', dispatch: React.Dispatch<any>) => {
177
const [keywords, setKeywords] = useState('')

packages/neuron-ui/src/components/Overview/index.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { showTransactionDetails, showErrorMessage } from 'services/remote'
2929

3030
import { localNumberFormatter, shannonToCKBFormatter, uniformTimeFormatter as timeFormatter } from 'utils/formatters'
3131
import { PAGE_SIZE, Routes, CONFIRMATION_THRESHOLD } from 'utils/const'
32+
import { backToTop } from 'utils/animations'
3233

3334
const TITLE_FONT_SIZE = 'xxLarge'
3435
export type ActivityItem = State.Transaction & { confirmations: string; typeLabel: string }
@@ -68,7 +69,7 @@ const ActivityList = ({
6869
onRenderRow?: IRenderFunction<IDetailsRowProps>
6970
[index: string]: any
7071
}>) => (
71-
<Stack>
72+
<Stack verticalFill>
7273
<DetailsList
7374
isHeaderVisible={false}
7475
layoutMode={DetailsListLayoutMode.justified}
@@ -81,6 +82,8 @@ const ActivityList = ({
8182
}}
8283
styles={{
8384
root: {
85+
overflow: 'auto',
86+
height: '100%',
8487
backgroundColor: 'transparent',
8588
},
8689
contentWrapper: {
@@ -121,6 +124,15 @@ const Overview = ({
121124
const blockchainInfoRef = useRef<HTMLDivElement>(null)
122125
const minerInfoRef = useRef<HTMLDivElement>(null)
123126

127+
useEffect(() => {
128+
if (id) {
129+
const activityListContainer = document.querySelector('.ms-DetailsList>div') as HTMLElement
130+
if (activityListContainer) {
131+
backToTop(activityListContainer)
132+
}
133+
}
134+
}, [id])
135+
124136
useEffect(() => {
125137
updateTransactionList({
126138
pageNo: 1,
@@ -281,10 +293,15 @@ const Overview = ({
281293
if (item.blockNumber !== undefined) {
282294
const confirmationCount = 1 + Math.max(+syncedBlockNumber, +tipBlockNumber) - +item.blockNumber
283295
typeLabel = genTypeLabel(item.type, confirmationCount)
284-
confirmations =
285-
confirmationCount > 1
286-
? `(${t('overview.confirmations', { confirmationCount: localNumberFormatter(confirmationCount) })})`
287-
: `(${t('overview.confirmation', { confirmationCount: localNumberFormatter(confirmationCount) })})`
296+
if (confirmationCount === 1) {
297+
confirmations = `(${t('overview.confirmation', {
298+
confirmationCount: localNumberFormatter(confirmationCount),
299+
})})`
300+
} else if (confirmationCount > 1) {
301+
confirmations = `(${t('overview.confirmations', {
302+
confirmationCount: localNumberFormatter(confirmationCount),
303+
})})`
304+
}
288305
}
289306
return {
290307
...item,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const backToTop = (elm?: HTMLElement) => {
2+
const container = elm || (document.querySelector('main > div') as HTMLElement)
3+
if (container) {
4+
container.scrollIntoView({
5+
behavior: 'smooth',
6+
block: 'start',
7+
inline: 'nearest',
8+
})
9+
}
10+
}
11+
12+
export default {
13+
backToTop,
14+
}

0 commit comments

Comments
 (0)