Repository: twentyhq/twenty
File: packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellEditButton.tsx (TypeScript)

Code before:
      : isFieldEmails(fieldDefinition)
        ? t`Email address copied to clipboard`
        : t`Link copied to clipboard`;
    if (textToCopy) {
      await copyToClipboard(textToCopy, textMessage);
    }
  };

  const isNavigatePrimaryForField =
    onClickAction === FieldMetadataSettingsOnClickAction.OPEN_LINK;

  const secondaryClickForField = onClickAction
    ? isNavigatePrimaryForField
      ? handleCopyClick
      : handleNavigateClick
    : undefined;

  const secondaryIcon = onClickAction
    ? isNavigatePrimaryForField
      ? IconCopy
      : IconArrowUpRight
    : undefined;

  return (
    <RecordTableCellButton
      onClick={handleButtonClick}
      Icon={buttonIcon}
      onSecondaryClick={secondaryClickForField}
      SecondaryIcon={secondaryIcon}
    />
  );
};


Review comment (suggestion):
The primary button's onClick handler is always set to `handleButtonClick` (which opens the cell editor), even when the field has a configured click action (for phones, emails, or links). When `onClickAction` is defined, the primary button should execute the primary action based on the `isNavigatePrimaryForField` logic (either `handleNavigateClick` or `handleCopyClick`), not always open the cell editor. Consider changing the onClick prop to conditionally use the appropriate handler based on the click action configuration.

Code after:
import { useGetButtonIcon } from '@/object-record/record-field/ui/hooks/useGetButtonIcon';
import { useIsFieldInputOnly } from '@/object-record/record-field/ui/hooks/useIsFieldInputOnly';

import { RecordTableCellContext } from '@/object-record/record-table/contexts/RecordTableCellContext';
import { RecordTableCellButtons } from '@/object-record/record-table/record-table-cell/components/RecordTableCellButtons';
import { useGetSecondaryRecordTableCellButton } from '@/object-record/record-table/record-table-cell/hooks/useGetSecondaryRecordTableCellButton';
import { useOpenRecordTableCellFromCell } from '@/object-record/record-table/record-table-cell/hooks/useOpenRecordTableCellFromCell';
import { useContext } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { IconArrowUpRight, IconPencil } from 'twenty-ui/display';

export const RecordTableCellEditButton = () => {
  const { cellPosition } = useContext(RecordTableCellContext);
  const { openTableCell } = useOpenRecordTableCellFromCell();
  const isFieldInputOnly = useIsFieldInputOnly();
  const isFirstColumn = cellPosition.column === 0;
  const customButtonIcon = useGetButtonIcon();

  const secondaryButton = useGetSecondaryRecordTableCellButton();

  const mainButtonIcon = isFirstColumn
    ? IconArrowUpRight
    : isDefined(customButtonIcon)
      ? customButtonIcon
      : IconPencil;

  const handleMainButtonClick = () => {
    if (!isFieldInputOnly && isFirstColumn) {
      openTableCell(undefined, false, true);
    } else {
      openTableCell();
    }
  };

  return (
    <RecordTableCellButtons
      buttons={[
        ...secondaryButton,
        {
          onClick: handleMainButtonClick,
          Icon: mainButtonIcon,
        },
      ]}
    />
  );
};