Skip to content

Commit

Permalink
Fixes #7220: Remove primary banner icon when only one value present
Browse files Browse the repository at this point in the history
  • Loading branch information
KeeratK committed Sep 26, 2024
1 parent 7c90e71 commit e19d8bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const EmailsFieldInput = ({ onCancel }: EmailsFieldInputProps) => {
});
};

const isPrimaryEmail = (index: number) => index === 0 && emails?.length > 1;

return (
<MultiItemFieldInput
items={emails}
Expand All @@ -46,7 +48,7 @@ export const EmailsFieldInput = ({ onCancel }: EmailsFieldInputProps) => {
<EmailsFieldMenuItem
key={index}
dropdownId={`${hotkeyScope}-emails-${index}`}
isPrimary={index === 0}
isPrimary={isPrimaryEmail(index)}
email={email}
onEdit={handleEdit}
onSetAsPrimary={handleSetPrimary}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export const LinksFieldInput = ({ onCancel }: LinksFieldInputProps) => {
});
};

const isPrimaryLink = (index: number) => index === 0 && links?.length > 1;

return (
<MultiItemFieldInput
items={links}
Expand All @@ -61,7 +63,7 @@ export const LinksFieldInput = ({ onCancel }: LinksFieldInputProps) => {
<LinksFieldMenuItem
key={index}
dropdownId={`${hotkeyScope}-links-${index}`}
isPrimary={index === 0}
isPrimary={isPrimaryLink(index)}
label={link.label}
onEdit={handleEdit}
onSetAsPrimary={handleSetPrimary}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export const PhonesFieldInput = ({ onCancel }: PhonesFieldInputProps) => {
});
};

const isPrimaryPhone = (index: number) => index === 0 && phones?.length > 1;

return (
<MultiItemFieldInput
items={phones}
Expand Down Expand Up @@ -108,7 +110,7 @@ export const PhonesFieldInput = ({ onCancel }: PhonesFieldInputProps) => {
<PhonesFieldMenuItem
key={index}
dropdownId={`${hotkeyScope}-phones-${index}`}
isPrimary={index === 0}
isPrimary={isPrimaryPhone(index)}
phone={phone}
onEdit={handleEdit}
onSetAsPrimary={handleSetPrimary}
Expand Down

0 comments on commit e19d8bb

Please sign in to comment.