fix: 修复 crud 分页点击页面位置跳转问题 Close: #9667 (#10643)

This commit is contained in:
liaoxuezhi 2024-07-17 10:20:56 +08:00 committed by GitHub
parent 7682b0a4ca
commit a9c17bae20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 3 deletions

View File

@ -1,4 +1,8 @@
.#{$ns}Cards {
// 黑科技 scrollIntoView 能够跑正确的位置
margin-top: calc(var(--affix-offset-top) * -1);
padding-top: var(--affix-offset-top);
&-toolbar {
@include clearfix();
padding: var(--Cards-toolbar-marginY) var(--Cards-toolbar-marginX)

View File

@ -1,5 +1,8 @@
.#{$ns}List {
position: relative;
// 黑科技 scrollIntoView 能够跑正确的位置
margin-top: calc(var(--affix-offset-top) * -1);
padding-top: var(--affix-offset-top);
&-items {
border-radius: var(--List-borderRadius);

View File

@ -1,6 +1,10 @@
.#{$ns}Table {
position: relative;
// 黑科技 scrollIntoView 能够跑正确的位置
margin-top: calc(var(--affix-offset-top) * -1);
padding-top: var(--affix-offset-top);
border-radius: var(--Table-borderRadius);
margin-bottom: var(--gap-md);

View File

@ -1435,9 +1435,13 @@ export default class CRUD extends React.Component<CRUDProps, any> {
this.search(undefined, undefined, undefined);
if (autoJumpToTopOnPagerChange && this.control) {
(findDOMNode(this.control) as HTMLElement).scrollIntoView();
const scrolledY = window.scrollY;
scrolledY && window.scroll(0, scrolledY);
if (this.control.scrollToTop) {
this.control.scrollToTop();
} else {
(findDOMNode(this.control) as HTMLElement).scrollIntoView();
const scrolledY = window.scrollY;
scrolledY && window.scroll(0, scrolledY);
}
}
}

View File

@ -548,6 +548,7 @@ export default class Table extends React.Component<TableProps, object> {
resizable: true
};
dom = React.createRef<HTMLDivElement>();
table?: HTMLTableElement;
sortable?: Sortable;
dragTip?: HTMLElement;
@ -989,6 +990,15 @@ export default class Table extends React.Component<TableProps, object> {
scoped.unRegisterComponent(this);
}
scrollToTop() {
this.dom.current?.scrollIntoView();
if (this.props.autoFillHeight) {
this.table?.scrollIntoView();
}
const scrolledY = window.scrollY;
scrolledY && window.scroll(0, scrolledY);
}
rowPathPlusOffset(path: string, offset = 0) {
const list = path.split('.').map((item: any) => parseInt(item, 10));
list[0] += offset;
@ -2830,6 +2840,7 @@ export default class Table extends React.Component<TableProps, object> {
return (
<div
ref={this.dom}
className={cx('Table', {'is-mobile': mobileUI}, className, {
'Table--unsaved': !!store.modified || !!store.moved,
'Table--autoFillHeight': autoFillHeight