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

[BUGFIX] Account owner should not be clickable & [Refactor] Chip.tsx links #10359

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

Conversation

prastoin
Copy link
Contributor

@prastoin prastoin commented Feb 20, 2025

Introduction

Initially fixing the Account Owner record field value should not be clickable and redirects on current page bug.
This has been fixed computing whereas the current filed is a workspace member dynamically rendering a stale Chip components instead of an interactive one

Refactor

Refactored the AvatarChip to props logic to be scoped to lower level scope Chip.
Now we have LinkChip Chip, LinkAvatarChip and AvatarChip all exported from twenty-ui.

The caller has to determine which one to call from the design system

New rule regarding chip links

As discussed with @charlesBochet and @FelixMalfait
A chip link will now always have to defined. ( and optionally an onClick ).
ChipLinks cannot be used as buttons anymore

Factorization

Deleted the RecordIndexRecordChip.tsx file ( aka RecordIdentifierChip component ) that was duplicating some logic, refactored the RecordChip in order to handle what was covered by RecordIdentifierChip

Conclusion

As always any suggestions are more than welcomed ! Took few opinionated decision/refactor regarding nested long ternaries rendering ReactNode elements

Misc

Screen.Recording.2025-02-24.at.19.18.22.mov

@prastoin prastoin force-pushed the prastoin-bugfix-10196 branch from 65d77a2 to 89292dd Compare February 24, 2025 10:35
Copy link
Contributor

github-actions bot commented Feb 24, 2025

TODOs/FIXMEs:

  • // TODO temporary until we create a record show page for Workspaces members: packages/twenty-front/src/modules/object-record/components/RecordChip.tsx
  • // TODO refactor wrapper event listener to avoid colliding events: packages/twenty-front/src/modules/object-record/components/RecordChip.tsx

Generated by 🚫 dangerJS against 86bdb37

@prastoin prastoin changed the title [BUGFIX] Account owner should not be clickable [BUGFIX] Account owner should not be clickable and Refactor Chip.tsx Feb 24, 2025
@prastoin prastoin marked this pull request as ready for review February 24, 2025 15:35
@prastoin prastoin self-assigned this Feb 24, 2025
@prastoin prastoin changed the title [BUGFIX] Account owner should not be clickable and Refactor Chip.tsx [BUGFIX] Account owner should not be clickable & [Refactor] Chip.tsx links Feb 24, 2025
@prastoin
Copy link
Contributor Author

@greptileai trigger

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

Great!!!

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 refactors chip components to enforce consistent link behavior and fixes the Account Owner field clickability issue, introducing a clearer separation between linked and non-linked chips.

  • Introduced new LinkChip and LinkAvatarChip components in /packages/twenty-ui/src/display/chip/components/ to handle link-specific functionality
  • Added forceDisableClick prop in /packages/twenty-front/src/modules/object-record/components/RecordChip.tsx to prevent workspace member fields from being clickable
  • Extracted avatar chip logic into new useGetAvatarChipLeftComponentAndVariant hook in /packages/twenty-ui/src/display/chip/hooks/
  • Added isModifiedEvent utility in /packages/twenty-ui/src/utilities/events/ for standardized handling of modified click events
  • Removed duplicate code by deleting RecordIndexRecordChip.tsx and consolidating functionality into RecordChip

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

@@ -145,7 +149,7 @@ export const AttachmentRow = ({

const handleOpenDocument = (e: React.MouseEvent) => {
// Cmd/Ctrl+click opens new tab, right click opens context menu
if (e.metaKey || e.ctrlKey || e.button === 2) {
if (isModifiedEvent(e) || e.button === 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider adding e.button === 1 check for middle mouse button clicks which also typically open in new tab

? getLinkToShowPage(objectNameSingular, record)
: undefined
}
to={to ?? getLinkToShowPage(objectNameSingular, record)}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: getLinkToShowPage could return undefined, which would make the to prop undefined. According to the PR description, LinkChip must always have a defined to prop.

Copy link
Contributor Author

@prastoin prastoin Feb 24, 2025

Choose a reason for hiding this comment

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

If it's true you're a veryyy gooood bot, if not I still love you

Comment on lines +38 to +40
return (
<StyledLink to={to} onClick={onClick}>
<Chip
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The disabled prop is not being passed to StyledLink, which means disabled chips will still be clickable links

Suggested change
return (
<StyledLink to={to} onClick={onClick}>
<Chip
return disabled ? (
<Chip

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.

3 participants