Skip to content

Commit

Permalink
Fix RICH_TEXT display on cell (#8676)
Browse files Browse the repository at this point in the history
## Context
We added a check of the field type in
[useTextFieldDisplay.ts](https://github.com/twentyhq/twenty/compare/c--fix-rich-text-display?expand=1#diff-8e53a2496b9faa67ac9aad3f7016efed19147557904da1bc44e895688513330d)
however this hook is also used for RICH_TEXT fields so it fails.
I'm removing this check since I don't think this is necessary, the
caller should already know its a TEXT or RICH_TEXT
  • Loading branch information
Weiko authored Nov 22, 2024
1 parent 76be1df commit ac9cf73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useTextFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useTextFieldDisplay';
import { isFieldText } from '@/object-record/record-field/types/guards/isFieldText';
import { TextDisplay } from '@/ui/field/display/components/TextDisplay';

export const TextFieldDisplay = () => {
const { fieldValue, fieldDefinition } = useTextFieldDisplay();

return (
<TextDisplay
text={fieldValue}
displayedMaxRows={fieldDefinition.metadata?.settings?.displayedMaxRows}
/>
);
const displayedMaxRows = isFieldText(fieldDefinition)
? fieldDefinition.metadata?.settings?.displayedMaxRows
: 1;

return <TextDisplay text={fieldValue} displayedMaxRows={displayedMaxRows} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ import { useContext } from 'react';

import { useRecordFieldValue } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext';

import { assertFieldMetadata } from '@/object-record/record-field/types/guards/assertFieldMetadata';
import { isFieldText } from '@/object-record/record-field/types/guards/isFieldText';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { FieldContext } from '../../contexts/FieldContext';

export const useTextFieldDisplay = () => {
const { recordId, fieldDefinition, hotkeyScope } = useContext(FieldContext);

assertFieldMetadata(FieldMetadataType.Text, isFieldText, fieldDefinition);
const fieldName = fieldDefinition.metadata.fieldName;

const fieldValue =
Expand Down

0 comments on commit ac9cf73

Please sign in to comment.