Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
fix(ActionList): do not truncate description by default#5169
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a26447e8e900aa72d9d4a1239c136765fb38cc03e1f59b0cf61c3a354d4f4b55b237f5323db8c9a78287c6c2ec5713082b6e3b3ef4081b89File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@primer/react": minor | ||
| --- | ||
| fix(ActionList): do not truncate description by default |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -14,19 +14,24 @@ export type ActionListDescriptionProps = { | ||
| */ | ||
| variant?: 'inline' | 'block' | ||
| className?: string | ||
| /** | ||
| * Whether the inline description should truncate the text on overflow. | ||
| */ | ||
| truncate?: boolean | ||
| } & SxProp | ||
| export const Description: React.FC<React.PropsWithChildren<ActionListDescriptionProps>> = ({ | ||
| variant = 'inline', | ||
| sx = {}, | ||
| className, | ||
| truncate, | ||
| ...props | ||
| }) => { | ||
| const styles = { | ||
| fontSize: 0, | ||
| lineHeight: '16px', | ||
| flexGrow: 1, | ||
| flexBasis: 0, | ||
| flexBasis: variant === 'inline' && !truncate ? 'auto' : 0, | ||
| minWidth: 0, | ||
| marginLeft: variant === 'block' ? 0 : 2, | ||
| color: 'fg.muted', | ||
| @@ -37,11 +42,11 @@ export const Description: React.FC<React.PropsWithChildren<ActionListDescription | ||
| const {blockDescriptionId, inlineDescriptionId} = React.useContext(ItemContext) | ||
| return variant === 'block' ? ( | ||
| return variant === 'block' || !truncate ? ( | ||
| <Box | ||
| as="span" | ||
| sx={merge(styles, sx as SxProp)} | ||
| id={blockDescriptionId} | ||
| id={variant === 'block' ? blockDescriptionId : inlineDescriptionId} | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know we have different IDs for inline and block 💭 good to know MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was surprised by this one as well hahaah | ||
| className={className} | ||
| data-component="ActionList.Description" | ||
| > | ||
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.
Very detail tests!! Love it 🔥
I’m also curious to learn when you prefer to use Jest for visual style testing versus a tool like Playwright. 👀
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.
That's a great question! I actually didn't take the fact that we already had a playwright test for the truncation story into account when writing these so this might be a bit "overkill" haha. I think I tend to go for Jest because it's what I'm most familiar with but love how "complete" vrt testing is in that it'll fail on the smallest visual change in the entire story so it feels like it covers more ground than a specific jest test. That being said I'm a big fan of redundancy.
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.
Love this!