Skip to content

Commit 8bd52ea

Browse files
authored
fix: 修复编辑器v2 干员选择回到顶部的bug (#432)
2 parents 0fcf052 + ba3561a commit 8bd52ea

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/components/editor/operator/sheet/sheetOperator/toolBox/OperatorBackToTop.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export const OperatorBackToTop: FC<OperatorBackToTopProp> = ({ toTop }) => {
2727
t.components.editor.operator.sheet.sheetOperator.toolbox
2828
.OperatorBackToTop.back_to_top
2929
}
30-
onClick={() => setPaginationFilter(defaultPagination)}
30+
onClick={() => {
31+
setPaginationFilter(defaultPagination)
32+
toTop()
33+
}}
3134
/>
3235
)
3336
}

src/components/editor2/operator/sheet/SheetList.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ export const SheetList: FC<SheetListProps> = () => {
1212
const operatorScrollRef = useRef<HTMLDivElement>(null)
1313

1414
const toTop = useCallback(
15-
() => operatorScrollRef?.current?.scrollIntoView(),
15+
() =>
16+
operatorScrollRef?.current?.scrollIntoView({
17+
behavior: 'smooth',
18+
block: 'start',
19+
inline: 'nearest',
20+
}),
1621
[operatorScrollRef],
1722
)
1823

@@ -22,12 +27,13 @@ export const SheetList: FC<SheetListProps> = () => {
2227

2328
return (
2429
<div className="flex h-full">
25-
<div className="grow px-1 py-4 overflow-auto" ref={operatorScrollRef}>
30+
<div className="grow px-1 py-4 overflow-auto">
2631
{operatorFilteredData.length ? (
2732
<>
2833
<div
2934
key="operatorContainer"
3035
className="flex flex-wrap items-start content-start overscroll-contain relative"
36+
ref={operatorScrollRef}
3137
>
3238
{operatorFilteredData.map(({ name }, index) => (
3339
<div className="flex items-center flex-0 w-32 h-32" key={index}>

0 commit comments

Comments
 (0)