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

Clicking a phone number should copy its value #9069

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Lucifer4255
Copy link
Contributor

All.-.People.-.Google.Chrome.2024-12-13.23-31-08.mp4

I have added the functionality of copying the phone number to clipboard according to the issue #8905 . If anything needed to change just comment in my PR

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.

PR Summary

This PR adds clipboard copy functionality when clicking phone numbers, replacing the default phone app navigation behavior with a success notification upon copying.

  • Added click handler in packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx to copy phone numbers to clipboard
  • Click handler only works in focused view, needs to be added to unfocused state for consistency
  • Missing error handling notification when clipboard copy fails
  • Inconsistent handling of undefined phone numbers could cause runtime errors
  • Should consider preserving phone app navigation as secondary action (e.g. ctrl+click)

💡 (5/5) You can turn off certain types of comments like style here!

1 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -30,6 +38,29 @@ const StyledContainer = styled.div`
`;

export const PhonesDisplay = ({ value, isFocused }: PhonesDisplayProps) => {
const { enqueueSnackBar } = useSnackBar();
Copy link
Member

Choose a reason for hiding this comment

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

let's not call the snackar in such a low component. Instead we should be able to pass call back to the PhoneDisplay component: onPhoneClick and implement the copy behavior (and snackbar) in PhonesFieldMenuItem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay ill update the copy behaviour

Copy link
Contributor Author

@Lucifer4255 Lucifer4255 Dec 17, 2024

Choose a reason for hiding this comment

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

@charlesBochet Hi charles im not quite sure about implementing the snackbar in phonesFieldMenuItem as i saw the action that if we click on the dropdown then the component is summoned but our main purpose is to copy when its clicked on the chip so im quite not sure why do i implement it there

Copy link
Member

Choose a reason for hiding this comment

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

because the PhoneDisplay is too low level (UI) and should not take dependency on the snackbar.
Instead it could expose a prop: onPhoneNumberClick that would allow the parent to decide what to do with this click event (here copy to the copyboard + display snackbar toast)

event.preventDefault(); // Prevent default link behavior

try {
if(phoneNumber !== undefined){
Copy link
Member

Choose a reason for hiding this comment

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

is isDefined helper + linter does not seem to be effective (npx nx run twenty-front:lint:ci)

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Lucifer4255, I have left comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Planned
Development

Successfully merging this pull request may close these issues.

2 participants