diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue index c23da09b7..8c2a5d120 100644 --- a/apps/desktop/src/components/grid/DataGrid.vue +++ b/apps/desktop/src/components/grid/DataGrid.vue @@ -286,6 +286,7 @@ function typeColorClass(t: string): string { } const contextCell = ref<{ rowId: number; rowIndex: number; col: number } | null>(null); const detailCell = ref<{ rowIndex: number; col: number } | null>(null); +const hoveredDetailCell = ref<{ rowIndex: number; col: number } | null>(null); const showCellDetail = ref(false); const activeCellDetailTab = ref(defaultCellDetailTab()); const detailWidth = ref(320); @@ -1734,6 +1735,24 @@ const multiRowCount = computed(() => { const isMultiRow = computed(() => multiRowCount.value > 1); +function onCellMouseenter(rowIndex: number, visibleColIdx: number, actualColIdx: number) { + hoveredDetailCell.value = { rowIndex, col: actualColIdx }; + extendCellSelection(rowIndex, visibleColIdx); +} + +function onCellMouseleave(rowIndex: number, actualColIdx: number) { + if (hoveredDetailCell.value?.rowIndex === rowIndex && hoveredDetailCell.value.col === actualColIdx) { + hoveredDetailCell.value = null; + } +} + +function cellDetailButtonVisible(rowIndex: number, actualColIdx: number) { + return ( + (hoveredDetailCell.value?.rowIndex === rowIndex && hoveredDetailCell.value.col === actualColIdx) || + (showCellDetail.value && detailCell.value?.rowIndex === rowIndex && detailCell.value.col === actualColIdx) + ); +} + function affectedRowIds(): number[] { if (hasRowSelection.value && selectedRowCount.value > 0) { return [...selectedRowIds.value]; @@ -4039,7 +4058,8 @@ defineExpose({ 'line-through': item.isDeleted, }" @mousedown="handleDataCellMousedown(index, visibleColIdx, item.id, $event)" - @mouseenter="extendCellSelection(index, visibleColIdx)" + @mouseenter="onCellMouseenter(index, visibleColIdx, actualColIdx)" + @mouseleave="onCellMouseleave(index, actualColIdx)" @dblclick="canEditCellItem(item, actualColIdx) && startEdit(item.id, actualColIdx)" :data-visible-col-index="visibleColIdx" @contextmenu="onCellContext(item.id, index, actualColIdx, visibleColIdx)" @@ -4067,7 +4087,8 @@ defineExpose({