Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
ActionList.Item: Bug fix to support both inline and block description at the same time#3945
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
5756ee5e5fcf9bf4f90e97671760062ccf775aa5d454f7821c1a272fFile 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": patch | ||
| --- | ||
| ActionList: Fix bug that did not allow both inline and block description at the same time |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -36,8 +36,10 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>( | ||
| const [slots, childrenWithoutSlots] = useSlots(props.children, { | ||
| leadingVisual: LeadingVisual, | ||
| trailingVisual: TrailingVisual, | ||
| description: Description, | ||
| blockDescription: [Description, props => props.variant === 'block'], | ||
| inlineDescription: [Description, props => props.variant !== 'block'], | ||
Contributor 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. Something I don't understand is why not have two different slots for block and inline description? Is it to avoid breaking changes? 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. Yep, that would be a breaking change. We used to support it before the regression. But also, this feels like an implementation detail, I don't personally like the idea of it leaking out into the API with | ||
| }) | ||
| const { | ||
| variant: listVariant, | ||
| role: listRole, | ||
| @@ -204,10 +206,8 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>( | ||
| onKeyPress: keyPressHandler, | ||
| 'aria-disabled': disabled ? true : undefined, | ||
| tabIndex: disabled ? undefined : 0, | ||
| 'aria-labelledby': `${labelId} ${ | ||
| slots.description && slots.description.props.variant !== 'block' ? inlineDescriptionId : '' | ||
| }`, | ||
| 'aria-describedby': slots.description?.props.variant === 'block' ? blockDescriptionId : undefined, | ||
| 'aria-labelledby': `${labelId} ${slots.inlineDescription ? inlineDescriptionId : ''}`, | ||
| 'aria-describedby': slots.blockDescription ? blockDescriptionId : undefined, | ||
| ...(selectionAttribute && {[selectionAttribute]: selected}), | ||
| role: role || itemRole, | ||
| id: itemId, | ||
| @@ -235,26 +235,25 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>( | ||
| > | ||
| <ConditionalBox if={Boolean(slots.trailingVisual)} sx={{display: 'flex', flexGrow: 1}}> | ||
| <ConditionalBox | ||
| if={!!slots.description && slots.description.props.variant !== 'block'} | ||
| if={!!slots.inlineDescription} | ||
| sx={{display: 'flex', flexGrow: 1, alignItems: 'baseline', minWidth: 0}} | ||
| > | ||
| <Box | ||
| as="span" | ||
| id={labelId} | ||
| sx={{ | ||
| flexGrow: slots.description && slots.description.props.variant !== 'block' ? 0 : 1, | ||
| fontWeight: slots.description ? 'bold' : 'normal', | ||
| marginBlockEnd: | ||
| slots.description && slots.description.props.variant !== 'inline' ? '4px' : undefined, | ||
| flexGrow: slots.inlineDescription ? 0 : 1, | ||
| fontWeight: slots.inlineDescription || slots.blockDescription ? 'bold' : 'normal', | ||
| marginBlockEnd: slots.blockDescription ? '4px' : undefined, | ||
| }} | ||
| > | ||
| {childrenWithoutSlots} | ||
| </Box> | ||
| {slots.description?.props.variant !== 'block' ? slots.description : null} | ||
| {slots.inlineDescription} | ||
| </ConditionalBox> | ||
| {slots.trailingVisual} | ||
| </ConditionalBox> | ||
| {slots.description?.props.variant === 'block' ? slots.description : null} | ||
| {slots.blockDescription} | ||
| </Box> | ||
| </ItemWrapper> | ||
| </LiBox> | ||
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.
The margin after item was added in Bug fix: ActionList item label weight and spacing if description exists #3490, this was the code:
The intention seems to be to only add margin when description
variant !== 'inline', so block description?I'm not sure if the condition is intentional or not, because the condition would also be true when
props.variantis not passed, which defaults toinline(undefined !== 'inline')I have removed the margin here, tagging @langermank to confirm that was the intention with Bug fix: ActionList item label weight and spacing if description exists #3490
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.
Thanks for tagging me! I think the change you made is correct, mostly just by looking at the snapshots. 🚀