fix: 컬럼 리사이즈 시 정렬이 트리거되는 문제 해결
문제: - 컬럼 너비를 조절할 때 자동으로 정렬이 실행됨 - 리사이즈 핸들 클릭이 헤더의 onClick 이벤트를 트리거 해결: - isResizing useRef 플래그 추가 - 리사이즈 시작 시 플래그를 true로 설정 - 헤더 onClick에서 isResizing.current 체크 - 리사이즈 중이면 정렬 실행 안함 - mouseup 후 100ms 지연으로 플래그 해제 적용: - TableListComponent - InteractiveDataTable 이제 컬럼 리사이즈가 정렬을 방해하지 않음
This commit is contained in:
parent
516bcafb2c
commit
f9bd7bbcb3
|
|
@ -109,6 +109,7 @@ export const InteractiveDataTable: React.FC<InteractiveDataTableProps> = ({
|
|||
const [columnWidths, setColumnWidths] = useState<Record<string, number>>({});
|
||||
const hasInitializedWidthsRef = useRef(false);
|
||||
const columnRefs = useRef<Record<string, HTMLTableCellElement | null>>({});
|
||||
const isResizingRef = useRef(false);
|
||||
|
||||
// SaveModal 상태 (등록/수정 통합)
|
||||
const [showSaveModal, setShowSaveModal] = useState(false);
|
||||
|
|
@ -1994,6 +1995,8 @@ export const InteractiveDataTable: React.FC<InteractiveDataTableProps> = ({
|
|||
const thElement = columnRefs.current[column.id];
|
||||
if (!thElement) return;
|
||||
|
||||
isResizingRef.current = true;
|
||||
|
||||
const startX = e.clientX;
|
||||
const startWidth = columnWidth || thElement.offsetWidth;
|
||||
|
||||
|
|
@ -2024,6 +2027,11 @@ export const InteractiveDataTable: React.FC<InteractiveDataTableProps> = ({
|
|||
document.body.style.userSelect = '';
|
||||
document.body.style.cursor = '';
|
||||
|
||||
// 약간의 지연 후 리사이즈 플래그 해제
|
||||
setTimeout(() => {
|
||||
isResizingRef.current = false;
|
||||
}, 100);
|
||||
|
||||
document.removeEventListener('mousemove', handleMouseMove);
|
||||
document.removeEventListener('mouseup', handleMouseUp);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -248,6 +248,7 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
const columnRefs = useRef<Record<string, HTMLTableCellElement | null>>({});
|
||||
const [isAllSelected, setIsAllSelected] = useState(false);
|
||||
const hasInitializedWidths = useRef(false);
|
||||
const isResizing = useRef(false);
|
||||
|
||||
// 필터 설정 관련 상태
|
||||
const [isFilterSettingOpen, setIsFilterSettingOpen] = useState(false);
|
||||
|
|
@ -1073,7 +1074,10 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
maxWidth: column.columnName === "__checkbox__" ? '48px' : undefined,
|
||||
userSelect: 'none'
|
||||
}}
|
||||
onClick={() => column.sortable && handleSort(column.columnName)}
|
||||
onClick={() => {
|
||||
if (isResizing.current) return;
|
||||
if (column.sortable) handleSort(column.columnName);
|
||||
}}
|
||||
>
|
||||
{column.columnName === "__checkbox__" ? (
|
||||
renderCheckboxHeader()
|
||||
|
|
@ -1098,6 +1102,8 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
const thElement = columnRefs.current[column.columnName];
|
||||
if (!thElement) return;
|
||||
|
||||
isResizing.current = true;
|
||||
|
||||
const startX = e.clientX;
|
||||
const startWidth = columnWidth || thElement.offsetWidth;
|
||||
|
||||
|
|
@ -1128,6 +1134,11 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
document.body.style.userSelect = '';
|
||||
document.body.style.cursor = '';
|
||||
|
||||
// 약간의 지연 후 리사이즈 플래그 해제 (클릭 이벤트가 먼저 처리되지 않도록)
|
||||
setTimeout(() => {
|
||||
isResizing.current = false;
|
||||
}, 100);
|
||||
|
||||
document.removeEventListener('mousemove', handleMouseMove);
|
||||
document.removeEventListener('mouseup', handleMouseUp);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue