Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-link-loading-wrapper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

fix(Button): Apply inline-flex display to loading wrapper for link variant buttons
4 changes: 4 additions & 0 deletions packages/react/src/Button/ButtonBase.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,10 @@
display: block;
}

.ConditionalWrapperLink {
display: inline-flex;
}

[data-kbd-chord] {
transition: 80ms ease-in;
transition-property: color, background-color, border-color;
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Button/ButtonBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const ButtonBase = forwardRef(({children, as: Component = 'button', ...props}, f
// when `loading` is `false`.
// Then, the component re-renders in a way that the button will lose focus when switching between loading states.
if={typeof loading !== 'undefined'}
className={block ? classes.ConditionalWrapper : undefined}
className={block ? classes.ConditionalWrapper : variant === 'link' ? classes.ConditionalWrapperLink : undefined}
data-loading-wrapper
>
<Component
Expand Down
12 changes: 12 additions & 0 deletions packages/react/src/Button/__tests__/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ describe('Button', () => {
expect(container.getByRole('button')).toHaveAccessibleName('content')
})

it('should apply inline-flex display to loading wrapper when variant is link', () => {
const {container} = render(
<Button variant="link" loading>
content
</Button>,
)

const wrapper = container.querySelector('[data-loading-wrapper]')
expect(wrapper).toBeInTheDocument()
expect(wrapper).toHaveClass(classes.ConditionalWrapperLink)
})

it('should render tooltip on an icon button when unsafeDisableTooltip prop is passed as false', () => {
const {getByRole, getByText} = render(<IconButton icon={HeartIcon} aria-label="Heart" />)
const triggerEL = getByRole('button')
Expand Down
Loading