-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat: add feature to customize onClick behaviour for phone, email and links data type #16265
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
base: main
Are you sure you want to change the base?
Conversation
Welcome!
Hello there, congrats on your first PR! We're excited to have you contributing to this project. |
Greptile OverviewGreptile SummaryAdded 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 ( Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
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
|
There was a problem hiding this 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
| export enum FieldClickAction { | ||
| COPY = 'COPY', | ||
| OPEN_LINK = 'OPEN_LINK', | ||
| } |
There was a problem hiding this comment.
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
| 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(), |
There was a problem hiding this comment.
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.There was a problem hiding this 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
FieldClickActionenum withCOPYandOPEN_LINKoptions 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)) { |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
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.
| if (clickAction === FieldClickAction.COPY || !isDefined(clickAction)) { | |
| if (clickAction === FieldClickAction.COPY) { |
There was a problem hiding this comment.
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)) { |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
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.
| if (clickAction === FieldClickAction.COPY && isDefined(onLinkClick)) { | |
| if (clickAction === FieldClickAction.COPY) { |
There was a problem hiding this comment.
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)) { |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
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.
| if (clickAction === FieldClickAction.COPY && isDefined(onEmailClick)) { | |
| if (clickAction === FieldClickAction.COPY) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
🚀 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. |
fe04f58 to
0d32241
Compare
…d links data type Issue: twentyhq#15797
0d32241 to
bc8d4fd
Compare
|
@FelixMalfait @Bonapara Can I get a review on this one ? |
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:
The default behaviour is persisted for all these three types(phone- Copy to clipboard, email & links: open link) to maintain backward compatibility.
Screenshots :
