-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
base: main
Are you sure you want to change the base?
Conversation
65d77a2
to
89292dd
Compare
TODOs/FIXMEs:
|
Chip.tsx
Chip.tsx
Chip.tsx
links
@greptileai trigger |
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.
Great!!!
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.
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
andLinkAvatarChip
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 intoRecordChip
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) { |
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: 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)} |
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.
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.
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.
If it's true you're a veryyy gooood bot, if not I still love you
return ( | ||
<StyledLink to={to} onClick={onClick}> | ||
<Chip |
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.
logic: The disabled prop is not being passed to StyledLink, which means disabled chips will still be clickable links
return ( | |
<StyledLink to={to} onClick={onClick}> | |
<Chip | |
return disabled ? ( | |
<Chip |
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 scopeChip
.Now we have
LinkChip
Chip
,LinkAvatarChip
andAvatarChip
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 anonClick
).ChipLinks
cannot be used as buttons anymoreFactorization
Deleted the
RecordIndexRecordChip.tsx
file ( akaRecordIdentifierChip
component ) that was duplicating some logic, refactored theRecordChip
in order to handle what was covered byRecordIdentifierChip
Conclusion
As always any suggestions are more than welcomed ! Took few opinionated decision/refactor regarding nested long ternaries rendering
ReactNode
elementsMisc
Screen.Recording.2025-02-24.at.19.18.22.mov