Skip to content

Commit

Permalink
fix(home): 元素不应该超出窗口底部
Browse files Browse the repository at this point in the history
  • Loading branch information
XYShaoKang committed Feb 25, 2023
1 parent 757bbd5 commit efb04ea
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/content/pages/home/BlockUserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ const BlockUserList: FC<BlockUserListProps> = props => {
const [errorMessage, setErrorMessage] = useState('')
const timer = useRef<ReturnType<typeof setTimeout>>()
const dispatch = useAppDispatch()
const [top, setTop] = useState(0)

const listRef = (ref: HTMLUListElement) => {
setTop(ref?.getBoundingClientRect().top ?? 0)
}

const showMessage = (error: string) => {
hideMessage()
Expand Down Expand Up @@ -221,7 +226,14 @@ const BlockUserList: FC<BlockUserListProps> = props => {
</div>
</ToolTip>
</div>
<List style={{ marginTop: users.length ? 10 : 0 }}>
<List
ref={listRef}
style={{
marginTop: users.length ? 10 : 0,
maxHeight: `calc(100vh - ${top + 10}px)`,
overflowY: 'auto',
}}
>
{users.map(({ slug, name, block }) => (
<Item key={slug}>
<div
Expand Down

0 comments on commit efb04ea

Please sign in to comment.