chore: Compatible with client data when cell type and field type are inconsistent (#75)

This commit is contained in:
Kilu.He
2025-09-17 16:22:03 +08:00
committed by GitHub
parent a8df225464
commit 7e8b049346
4 changed files with 8 additions and 11 deletions

View File

@@ -1,8 +1,8 @@
import { FC, useMemo } from 'react';
import { Cell as CellType, CellProps } from '@/application/database-yjs/cell.type';
import { CellProps, Cell as CellType } from '@/application/database-yjs/cell.type';
import { FieldType } from '@/application/database-yjs/database.type';
import { useCellSelector, useFieldSelector } from '@/application/database-yjs/selector';
import { useFieldSelector } from '@/application/database-yjs/selector';
import { YjsDatabaseKey } from '@/application/types';
import { AITextCell } from '@/components/database/components/cell/ai-text/AITextCell';
import { CheckboxCell } from '@/components/database/components/cell/checkbox';
@@ -20,7 +20,6 @@ export function Cell(props: CellProps<CellType>) {
const { rowId, fieldId, style, wrap, isHovering } = props;
const { field } = useFieldSelector(fieldId);
const fieldType = Number(field?.get(YjsDatabaseKey.type)) as FieldType;
const cell = useCellSelector({ rowId, fieldId });
const Component = useMemo(() => {
switch (fieldType) {
@@ -65,10 +64,6 @@ export function Cell(props: CellProps<CellType>) {
);
}
if (cell && cell.fieldType !== fieldType) {
return null;
}
return <Component {...props} />;
}

View File

@@ -1,10 +1,11 @@
import { useCallback, useMemo } from 'react';
import { FieldType, parseSelectOptionTypeOptions, useFieldSelector } from '@/application/database-yjs';
import { CellProps, SelectOptionCell as SelectOptionCellType } from '@/application/database-yjs/cell.type';
import { Tag } from '@/components/_shared/tag';
import { SelectOptionColorMap, SelectOptionFgColorMap } from '@/components/database/components/cell/cell.const';
import SelectOptionCellMenu from '@/components/database/components/cell/select-option/SelectOptionCellMenu';
import { Tag } from '@/components/_shared/tag';
import { cn } from '@/lib/utils';
import { useCallback, useMemo } from 'react';
export function SelectOptionCell({
editing,

View File

@@ -1,7 +1,7 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { FieldType, useCellSelector, useFieldWrap, useReadOnly } from '@/application/database-yjs';
import { Cell as CellType, CellProps } from '@/application/database-yjs/cell.type';
import { CellProps, Cell as CellType } from '@/application/database-yjs/cell.type';
import { useFieldSelector } from '@/application/database-yjs/selector';
import { FieldId, YjsDatabaseKey } from '@/application/types';
import { Cell } from '@/components/database/components/cell';
@@ -71,6 +71,7 @@ export function GridRowCell({ rowId, fieldId }: GridCellProps) {
const isActive = activeCell?.rowId === rowId && activeCell?.fieldId === fieldId;
const setEditing = useCallback(
(status: boolean) => {
if (status) {

View File

@@ -342,7 +342,7 @@ export const DatabaseTabs = forwardRef<HTMLDivElement, DatabaseTabBarProps>(
: ViewLayout.Grid,
}
}
className={'!h-5 !w-5 text-base'}
className={'!h-5 !w-5 text-base leading-[1.3rem]'}
/>
<Tooltip delayDuration={500}>