Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

truncate the string if overlow the text #6166

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isNonEmptyString } from '@sniptt/guards';

import { useFullNameFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useFullNameFieldDisplay';
import { TextDisplay } from '@/ui/field/display/components/TextDisplay';
import { OverflowingTextWithTooltip } from 'twenty-ui';

export const FullNameFieldDisplay = () => {
const { fieldValue } = useFullNameFieldDisplay();
Expand All @@ -10,5 +10,5 @@ export const FullNameFieldDisplay = () => {
.filter(isNonEmptyString)
.join(' ');

return <TextDisplay text={content} />;
return <OverflowingTextWithTooltip text={content} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTextFieldDisplay } from '@/object-record/record-field/meta-types/hoo
import { TextDisplay } from '@/ui/field/display/components/TextDisplay';

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

return <TextDisplay text={fieldValue} maxWidth={maxWidth} />;
return <TextDisplay text={fieldValue} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import { useRecordFieldValue } from '@/object-record/record-store/contexts/Recor
import { FieldContext } from '../../contexts/FieldContext';

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

const fieldName = fieldDefinition.metadata.fieldName;

const fieldValue =
useRecordFieldValue<string | undefined>(entityId, fieldName) ?? '';

return {
maxWidth,
fieldDefinition,
fieldValue,
hotkeyScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ import { RecordInlineCellContainer } from './RecordInlineCellContainer';
type RecordInlineCellProps = {
readonly?: boolean;
loading?: boolean;
isCentered?: boolean;
};

// TODO: refactor props drilling with a RecordInlineCellContext
export const RecordInlineCell = ({
readonly,
loading,
isCentered,
}: RecordInlineCellProps) => {
const { fieldDefinition, entityId } = useContext(FieldContext);
const buttonIcon = useGetButtonIcon();
Expand Down Expand Up @@ -86,6 +89,7 @@ export const RecordInlineCell = ({
label={fieldDefinition.label}
labelWidth={fieldDefinition.labelWidth}
showLabel={fieldDefinition.showLabel}
isCentered={isCentered}
editModeContent={
<FieldInput
recordFieldInputdId={`${entityId}-${fieldDefinition?.metadata?.fieldName}`}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactElement, useContext } from 'react';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { ReactElement, useContext } from 'react';
import { AppTooltip, IconComponent, TooltipDelay } from 'twenty-ui';

import { FieldContext } from '@/object-record/record-field/contexts/FieldContext';
Expand Down Expand Up @@ -52,6 +52,8 @@ const StyledInlineCellBaseContainer = styled.div`
gap: ${({ theme }) => theme.spacing(1)};

user-select: none;

justify-content: center;
`;

export const StyledSkeletonDiv = styled.div`
Expand All @@ -72,8 +74,10 @@ export type RecordInlineCellContainerProps = {
isDisplayModeFixHeight?: boolean;
disableHoverEffect?: boolean;
loading?: boolean;
isCentered?: boolean;
};

// TODO: refactor props drilling with a RecordInlineCellContext
export const RecordInlineCellContainer = ({
readonly,
IconLabel,
Expand All @@ -88,6 +92,7 @@ export const RecordInlineCellContainer = ({
isDisplayModeFixHeight,
disableHoverEffect,
loading = false,
isCentered,
}: RecordInlineCellContainerProps) => {
const { entityId, fieldDefinition } = useContext(FieldContext);

Expand Down Expand Up @@ -153,6 +158,7 @@ export const RecordInlineCellContainer = ({
loading,
readonly,
showLabel,
isCentered,
}}
/>
</StyledValueContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext } from 'react';
import { createPortal } from 'react-dom';
import styled from '@emotion/styled';
import { autoUpdate, flip, offset, useFloating } from '@floating-ui/react';
import { useContext } from 'react';
import { createPortal } from 'react-dom';

import { FieldContext } from '@/object-record/record-field/contexts/FieldContext';

Expand All @@ -19,7 +19,8 @@ const StyledInlineCellInput = styled.div`
display: flex;

min-height: 32px;
min-width: 200px;
min-width: 320px;

width: inherit;

z-index: 1000;
Expand All @@ -29,6 +30,7 @@ type RecordInlineCellEditModeProps = {
children: React.ReactNode;
};

// TODO: Refactor this to avoid setting absolute px values.
export const RecordInlineCellEditMode = ({
children,
}: RecordInlineCellEditModeProps) => {
Expand All @@ -41,7 +43,8 @@ export const RecordInlineCellEditMode = ({
offset(
isCentered
? {
mainAxis: -30,
mainAxis: -32,
crossAxis: 160,
}
: {
crossAxis: -4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ import { RecordInlineCellEditMode } from '@/object-record/record-inline-cell/com
import { RecordInlineCellSkeletonLoader } from '@/object-record/record-inline-cell/components/RecordInlineCellSkeletonLoader';
import { useInlineCell } from '@/object-record/record-inline-cell/hooks/useInlineCell';

const StyledClickableContainer = styled.div<{ readonly?: boolean }>`
const StyledClickableContainer = styled.div<{
readonly?: boolean;
isCentered?: boolean;
}>`
display: flex;
gap: ${({ theme }) => theme.spacing(1)};
width: 100%;

${({ isCentered }) =>
isCentered === true &&
`
justify-content: center;
`};

${({ readonly }) =>
!readonly &&
css`
Expand All @@ -33,6 +42,7 @@ type RecordInlineCellValueProps = Pick<
| 'loading'
| 'showLabel'
| 'label'
| 'isCentered'
>;

export const RecordInlineCellValue = ({
Expand All @@ -47,6 +57,7 @@ export const RecordInlineCellValue = ({
loading,
showLabel,
label,
isCentered,
}: RecordInlineCellValueProps) => {
const { isFocused } = useFieldFocus();

Expand All @@ -68,7 +79,7 @@ export const RecordInlineCellValue = ({
<RecordInlineCellEditMode>{editModeContent}</RecordInlineCellEditMode>
)}
{editModeContentOnly ? (
<StyledClickableContainer readonly={readonly}>
<StyledClickableContainer readonly={readonly} isCentered={isCentered}>
<RecordInlineCellDisplayMode
disableHoverEffect={disableHoverEffect}
isDisplayModeFixHeight={isDisplayModeFixHeight}
Expand All @@ -82,6 +93,7 @@ export const RecordInlineCellValue = ({
<StyledClickableContainer
readonly={readonly}
onClick={handleDisplayModeClick}
isCentered={isCentered}
>
<RecordInlineCellDisplayMode
disableHoverEffect={disableHoverEffect}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const RecordShowContainer = ({
isCentered: true,
}}
>
<RecordInlineCell readonly={isReadOnly} />
<RecordInlineCell readonly={isReadOnly} isCentered={true} />
</FieldContext.Provider>
}
avatarType={recordIdentifier?.avatarType ?? 'rounded'}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { OverflowingTextWithTooltip } from 'twenty-ui';

import { EllipsisDisplay } from './EllipsisDisplay';

type TextDisplayProps = {
text: string;
maxWidth?: number;
};

export const TextDisplay = ({ text, maxWidth }: TextDisplayProps) => (
<EllipsisDisplay maxWidth={maxWidth}>
<OverflowingTextWithTooltip text={text} />
</EllipsisDisplay>
export const TextDisplay = ({ text }: TextDisplayProps) => (
<OverflowingTextWithTooltip text={text} />
);
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styled from '@emotion/styled';
import {
ChangeEvent,
ClipboardEvent,
useEffect,
useRef,
useState,
} from 'react';
import styled from '@emotion/styled';
import { Key } from 'ts-key-enum';

import { FieldDoubleText } from '@/object-record/record-field/types/FieldDoubleText';
Expand All @@ -21,7 +21,7 @@ const StyledContainer = styled.div`
justify-content: space-between;

input {
width: ${({ theme }) => theme.spacing(24)};
width: 100%;
}

& > input:last-child {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const StyledTitle = styled.div`
font-size: ${({ theme }) => theme.font.size.xl};
font-weight: ${({ theme }) => theme.font.weight.semiBold};
justify-content: center;

width: 100%;
`;

const StyledAvatarWrapper = styled.div`
Expand Down
Loading