Skip to content

Conversation

@abk404
Copy link
Contributor

@abk404 abk404 commented Dec 2, 2025

Fixes Issue: #15797

This PR adds a configurable click behavior setting for Phone, Email, and Links field types, allowing users to customize what happens when clicking on these fields.

A new option (Click Behaviour) to configure the default behaviour for onClick of data is added in the settings page (Settings → Data Model → Object → Field Edit) for Phone, Email and Links data types.

Users can now choose between two actions:

  • Copy to clipboard: Copies the value to clipboard with a success toast message
  • Open as link: Opens the value as a link (tel:, mailto:, or http/https)

The default behaviour is persisted for all these three types(phone- Copy to clipboard, email & links: open link) to maintain backward compatibility.

Screenshots :
image

image image

Copilot AI review requested due to automatic review settings December 2, 2025 16:56
@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Welcome!

Hello there, congrats on your first PR! We're excited to have you contributing to this project.
By submitting your Pull Request, you acknowledge that you agree with the terms of our Contributor License Agreement.

Generated by 🚫 dangerJS against bc8d4fd

Copilot finished reviewing on behalf of abk404 December 2, 2025 16:59
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 2, 2025

Greptile Overview

Greptile Summary

Added configurable click behavior for Phone, Email, and Links field types, allowing users to choose between copying to clipboard or opening as a link. The feature integrates a new settings form (SettingsDataModelFieldClickBehaviorForm) that persists user preferences via the clickAction field in FieldMetadataMultiItemSettings.

Key Changes:

  • Created new FieldClickAction enum with COPY and OPEN_LINK options
  • Added click behavior configuration UI in field settings for PHONES, EMAILS, and LINKS types
  • Updated display components to read clickAction from field metadata and conditionally execute copy or link behaviors
  • Default behaviors: Phone fields default to COPY, Email and Link fields default to OPEN_LINK

Issues Found:

  • FieldClickAction uses enum instead of string literal union type, violating the codebase's TypeScript guidelines which require "Use string literal unions instead of enums" (exception: GraphQL enums)
  • The validation schema uses string literals instead of referencing the enum, creating inconsistency

Confidence Score: 4/5

  • This PR is safe to merge with one syntax issue that should be addressed
  • The implementation is solid and follows existing patterns in the codebase. The main issue is the use of enum instead of string literal union type, which violates TypeScript guidelines. This is a style/consistency issue rather than a functional bug. The feature logic is sound, with proper defaults, validation, and integration points.
  • Pay close attention to packages/twenty-shared/src/types/FieldMetadataMultiItemSettings.ts - the enum should be converted to a string literal union type per codebase guidelines

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-shared/src/types/FieldMetadataMultiItemSettings.ts 3/5 Added FieldClickAction enum (violates codebase guidelines - should use string literal union) and clickAction field to settings type
packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldClickBehaviorForm.tsx 5/5 New form component for configuring click behavior on phone, email, and link fields with proper type handling and i18n support
packages/twenty-front/src/modules/settings/data-model/fields/forms/utils/settingsDataModelFieldClickBehaviorSchema.ts 4/5 Validation schema for click behavior uses string literals ['COPY', 'OPEN_LINK'] instead of the enum, creating inconsistency
packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/EmailsFieldDisplay.tsx 5/5 Reads click action from field settings and implements copy-to-clipboard handler with toast notification
packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/PhonesFieldDisplay.tsx 5/5 Reads click action from field settings and conditionally executes copy handler based on click action preference

Sequence Diagram

sequenceDiagram
    participant User
    participant Settings as Settings UI
    participant ClickBehaviorForm as ClickBehaviorForm
    participant FieldMetadata as Field Metadata
    participant Display as Field Display Component
    participant Handler as Click Handler

    Note over User,Settings: Configuration Phase
    User->>Settings: Open field settings
    Settings->>ClickBehaviorForm: Render click behavior form
    ClickBehaviorForm->>FieldMetadata: Read existing clickAction setting
    FieldMetadata-->>ClickBehaviorForm: Return clickAction (or default)
    User->>ClickBehaviorForm: Select COPY or OPEN_LINK
    ClickBehaviorForm->>FieldMetadata: Save clickAction to settings
    
    Note over User,Handler: Runtime Phase
    User->>Display: Click on phone/email/link
    Display->>FieldMetadata: Read clickAction setting
    FieldMetadata-->>Display: Return clickAction value
    
    alt clickAction === COPY
        Display->>Handler: Call copy handler
        Handler->>Handler: Copy to clipboard
        Handler-->>User: Show success toast
    else clickAction === OPEN_LINK
        Display->>Handler: Default link behavior
        Handler-->>User: Open link in new tab
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +1 to +4
export enum FieldClickAction {
COPY = 'COPY',
OPEN_LINK = 'OPEN_LINK',
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Use string literal union instead of enum per TypeScript guidelines

Suggested change
export enum FieldClickAction {
COPY = 'COPY',
OPEN_LINK = 'OPEN_LINK',
}
export type FieldClickAction = 'COPY' | 'OPEN_LINK';
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-shared/src/types/FieldMetadataMultiItemSettings.ts
Line: 1:4

Comment:
**syntax:** Use string literal union instead of enum per TypeScript guidelines

```suggestion
export type FieldClickAction = 'COPY' | 'OPEN_LINK';
```

How can I resolve this? If you propose a fix, please make it concise.


export const settingsDataModelFieldClickBehaviorSchema = z.object({
settings: z.object({
clickAction: z.enum(['COPY', 'OPEN_LINK']).optional(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Inconsistent with FieldClickAction definition - if enum is changed to string literal union, this will need to reference it properly or use the type directly

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-front/src/modules/settings/data-model/fields/forms/utils/settingsDataModelFieldClickBehaviorSchema.ts
Line: 5:5

Comment:
**style:** Inconsistent with `FieldClickAction` definition - if enum is changed to string literal union, this will need to reference it properly or use the type directly

How can I resolve this? If you propose a fix, please make it concise.

@abk404 abk404 changed the title feat: add feature to customize on click behaviour for phone, email and links data type feat: add feature to customize onClick behaviour for phone, email and links data type Dec 2, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a configurable "Click Behavior" feature for Phone, Email, and Links field types, allowing users to choose between copying to clipboard or opening as a link when clicking these field values.

Key Changes:

  • Added FieldClickAction enum with COPY and OPEN_LINK options to the shared types package
  • Created form controls to configure click behavior per field type with appropriate defaults (Phone: COPY, Email/Links: OPEN_LINK)
  • Updated display components to conditionally handle clicks based on the configured click action

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/twenty-shared/src/types/index.ts Exports the new FieldClickAction enum for use across packages
packages/twenty-shared/src/types/FieldMetadataMultiItemSettings.ts Defines FieldClickAction enum and extends FieldMetadataMultiItemSettings to include clickAction property
packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldEdit.tsx Ensures settings field is properly initialized in the edit form
packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx Adds clickAction prop and conditional onClick handling based on click action setting
packages/twenty-front/src/modules/ui/field/display/components/LinksDisplay.tsx Adds clickAction prop and onClick handler that triggers copy behavior when configured
packages/twenty-front/src/modules/ui/field/display/components/EmailsDisplay.tsx Adds clickAction prop and onClick handler that triggers copy behavior when configured
packages/twenty-front/src/modules/settings/data-model/fields/forms/utils/settingsDataModelFieldClickBehaviorSchema.ts Defines Zod schema for click behavior form validation
packages/twenty-front/src/modules/settings/data-model/fields/forms/phones/components/SettingsDataModelFieldPhonesSettingsFormCard.tsx Integrates click behavior form into phone field settings
packages/twenty-front/src/modules/settings/data-model/fields/forms/phones/components/SettingsDataModelFieldPhonesForm.tsx Merges click behavior schema into phones field form schema
packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldSettingsFormCard.tsx Adds click behavior form to generic settings for emails and links fields
packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldClickBehaviorForm.tsx Implements the click behavior configuration UI with field-type-specific defaults and labels
packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/PhonesFieldDisplay.tsx Retrieves click action setting and passes it to display component with copy-to-clipboard handler
packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/LinksFieldDisplay.tsx Retrieves click action setting and implements copy-to-clipboard handler for links
packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/EmailsFieldDisplay.tsx Retrieves click action setting and implements copy-to-clipboard handler for emails

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

event: React.MouseEvent<HTMLElement>,
) => {
onPhoneNumberClick?.(number, event);
if (clickAction === FieldClickAction.COPY || !isDefined(clickAction)) {
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition || !isDefined(clickAction) is unnecessary because clickAction always has a default value (FieldClickAction.COPY) set in the parent component PhonesFieldDisplay. This check can be simplified to just if (clickAction === FieldClickAction.COPY) for consistency with the LinksDisplay and EmailsDisplay components.

Suggested change
if (clickAction === FieldClickAction.COPY || !isDefined(clickAction)) {
if (clickAction === FieldClickAction.COPY) {

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAKES SENSE, DONE

}, [value]);

const handleClick = (url: string, event: React.MouseEvent<HTMLElement>) => {
if (clickAction === FieldClickAction.COPY && isDefined(onLinkClick)) {
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition && isDefined(onLinkClick) is unnecessary because when clickAction === FieldClickAction.COPY, the parent component (LinksFieldDisplay) always provides the onLinkClick callback. This check can be simplified to just if (clickAction === FieldClickAction.COPY) for cleaner code.

Suggested change
if (clickAction === FieldClickAction.COPY && isDefined(onLinkClick)) {
if (clickAction === FieldClickAction.COPY) {

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

);

const handleClick = (email: string, event: React.MouseEvent<HTMLElement>) => {
if (clickAction === FieldClickAction.COPY && isDefined(onEmailClick)) {
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition && isDefined(onEmailClick) is unnecessary because when clickAction === FieldClickAction.COPY, the parent component (EmailsFieldDisplay) always provides the onEmailClick callback. This check can be simplified to just if (clickAction === FieldClickAction.COPY) for cleaner code.

Suggested change
if (clickAction === FieldClickAction.COPY && isDefined(onEmailClick)) {
if (clickAction === FieldClickAction.COPY) {

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:33378

This environment will automatically shut down when the PR is closed or after 5 hours.

@abk404 abk404 force-pushed the click_behaviour_feat branch 2 times, most recently from fe04f58 to 0d32241 Compare December 2, 2025 17:17
@abk404
Copy link
Contributor Author

abk404 commented Dec 4, 2025

@FelixMalfait @Bonapara Can I get a review on this one ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants