Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5654e5

Browse files
committed
fix virtualization layout issues
1 parent6b01a69 commite5654e5

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

‎client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { PrimaryColor } from "constants/style";
3030
import{trans}from"i18n";
3131
import_,{isEqual}from"lodash";
3232
import{darkenColor,isDarkColor,isValidColor,ScrollBar}from"lowcoder-design";
33-
importReact,{Children,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";
33+
importReact,{Children,useCallback,useContext,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";
3434
import{Resizable}from"react-resizable";
3535
importstyled,{css}from"styled-components";
3636
import{useMergeCompStyles,useUserViewMode}from"util/hooks";
@@ -498,10 +498,10 @@ const TableTdLoading = styled(Skeleton.Button)<SkeletonButtonProps & {
498498
}
499499
`;
500500

501-
constResizeableTitle=(props:any)=>{
501+
constResizeableTitle=React.forwardRef<HTMLTableHeaderCellElement,any>((props,ref)=>{
502502
const{ onResize, onResizeStop, width, viewModeResizable, ...restProps}=props;
503503
const[childWidth,setChildWidth]=useState(0);
504-
constresizeRef=useRef<HTMLDivElement>(null);
504+
constresizeRef=useRef<HTMLTableHeaderCellElement>(null);
505505
constisUserViewMode=useUserViewMode();
506506

507507
constupdateChildWidth=useCallback(()=>{
@@ -526,6 +526,8 @@ const ResizeableTitle = (props: any) => {
526526
};
527527
},[updateChildWidth]);
528528

529+
useImperativeHandle(ref,()=>resizeRef.current!,[]);
530+
529531
constisNotDataColumn=_.isNil(restProps.title);
530532
if((isUserViewMode&&!restProps.viewModeResizable)||isNotDataColumn){
531533
return<TableThref={resizeRef}{...restProps}width={width}/>;
@@ -559,7 +561,7 @@ const ResizeableTitle = (props: any) => {
559561
<TableThref={resizeRef}{...restProps}title=""/>
560562
</Resizable>
561563
);
562-
};
564+
});
563565

564566
typeCustomTableProps<RecordType>=Omit<TableProps<RecordType>,"components"|"columns">&{
565567
columns:CustomColumnType<RecordType>[];
@@ -579,7 +581,7 @@ type CustomTableProps<RecordType> = Omit<TableProps<RecordType>, "components" |
579581
};
580582
};
581583

582-
constTableCellView=React.memo((props:{
584+
constTableCellView=React.forwardRef<HTMLTableCellElement,{
583585
record:RecordType;
584586
title:string;
585587
rowColorFn:RowColorViewType;
@@ -594,7 +596,7 @@ const TableCellView = React.memo((props: {
594596
autoHeight?:boolean;
595597
loading?:boolean;
596598
customAlign?:'left'|'center'|'right';
597-
})=>{
599+
}>((props,ref)=>{
598600
const{
599601
record,
600602
title,
@@ -651,17 +653,23 @@ const TableCellView = React.memo((props: {
651653
};
652654
},[record,rowIndex,title,rowColorFn,rowHeightFn,cellColorFn,columnStyle,columnsStyle]);
653655

654-
lettdView;
655656
if(!record){
656-
tdView=<td{...restProps}>{children}</td>;
657-
}else{
658-
let{ background}=style!;
659-
if(rowContext.hover){
660-
background='transparent';
661-
}
657+
return(
658+
<TableCellContext.Providervalue={{isEditing:editing,setIsEditing:setEditing}}>
659+
<tdref={ref}{...restProps}>{children}</td>
660+
</TableCellContext.Provider>
661+
);
662+
}
662663

663-
tdView=(
664+
let{ background}=style!;
665+
if(rowContext.hover){
666+
background='transparent';
667+
}
668+
669+
return(
670+
<TableCellContext.Providervalue={{isEditing:editing,setIsEditing:setEditing}}>
664671
<TableTd
672+
ref={ref}
665673
{...restProps}
666674
$background={background}
667675
$style={style!}
@@ -677,17 +685,11 @@ const TableCellView = React.memo((props: {
677685
:children
678686
}
679687
</TableTd>
680-
);
681-
}
682-
683-
return(
684-
<TableCellContext.Providervalue={{isEditing:editing,setIsEditing:setEditing}}>
685-
{tdView}
686688
</TableCellContext.Provider>
687689
);
688690
});
689691

690-
constTableRowView=React.memo((props:any)=>{
692+
constTableRowView=React.forwardRef<HTMLTableRowElement,any>((props,ref)=>{
691693
const[hover,setHover]=useState(false);
692694
const[selected,setSelected]=useState(false);
693695

@@ -700,6 +702,7 @@ const TableRowView = React.memo((props: any) => {
700702
return(
701703
<TableRowContext.Providervalue={{ hover, selected}}>
702704
<tr
705+
ref={ref}
703706
{...props}
704707
tabIndex={-1}
705708
onMouseEnter={handleMouseEnter}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp