Skip to content
Merged
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/weak-ravens-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Bug fix: `Button` aria-expanded state (CSS Modules)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions e2e/components/Button.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,51 @@ test.describe('Button', () => {
})
}
})

test.describe('Aria expanded buttons', () => {
for (const theme of themes) {
test.describe(theme, () => {
test('default @vrt', async ({page}) => {
await visit(page, {
id: 'components-button-features--expanded-button',
globals: {
colorScheme: theme,
featureFlags: {
primer_react_css_modules_team: featureFlagOn,
},
},
})

// Default state
expect(await page.screenshot({animations: 'disabled'})).toMatchSnapshot(
`Button.Aria expanded buttons.${theme}.png`,
)
})

// temporarily disabled due to a bug in primer/primitves

// eslint-disable-next-line jest/no-commented-out-tests
// test('axe @aat', async ({page}) => {
// await visit(page, {
// id: 'components-button-features--expanded-button',
// globals: {
// colorScheme: theme,
// featureFlags: {
// primer_react_css_modules_team: featureFlagOn,
// },
// },
// })
// await expect(page).toHaveNoViolations({
// rules: {
// 'color-contrast': {
// enabled: theme !== 'dark_dimmed',
// },
// },
// })
// })
})
}
})
})
}
})
17 changes: 17 additions & 0 deletions packages/react/src/Button/Button.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,20 @@ export const InactiveButtonWithTooltip = () => (
<Button inactive>Review changes</Button>
</Tooltip>
)

export const ExpandedButton = () => (
<Stack align="start">
<Button aria-expanded trailingAction={TriangleDownIcon}>
Review changes
</Button>
<Button aria-expanded trailingAction={TriangleDownIcon} variant="primary">
Review changes
</Button>
<Button aria-expanded trailingAction={TriangleDownIcon} variant="invisible">
Review changes
</Button>
<Button aria-expanded trailingAction={TriangleDownIcon} variant="danger">
Review changes
</Button>
</Stack>
)
50 changes: 29 additions & 21 deletions packages/react/src/Button/ButtonBase.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@
background-color: var(--button-default-bgColor-rest);
box-shadow: var(--button-default-shadow-resting);

&[aria-expanded='true'] {
background-color: var(--button-default-bgColor-active);
border-color: var(--button-default-borderColor-active);
}

&:hover {
background-color: var(--button-default-bgColor-hover);
border-color: var(--button-default-borderColor-hover);
Expand All @@ -268,11 +273,6 @@
box-shadow: none;
}

&[aria-expanded='true'] {
background-color: var(--button-default-bgColor-active);
border-color: var(--button-default-borderColor-active);
}

& .CounterLabel {
background-color: var(--buttonCounter-default-bgColor-rest) !important; /* temporarily override our own sx prop */
}
Expand All @@ -290,6 +290,11 @@
border-color: var(--button-primary-borderColor-rest);
box-shadow: var(--shadow-resting-small);

&[aria-expanded='true'] {
background-color: var(--button-primary-bgColor-active);
box-shadow: var(--button-primary-shadow-selected);
}

&:hover {
background-color: var(--button-primary-bgColor-hover);
border-color: var(--button-primary-borderColor-hover);
Expand All @@ -312,11 +317,6 @@
box-shadow: none;
}

&[aria-expanded='true'] {
background-color: var(--button-primary-bgColor-active);
box-shadow: var(--button-primary-shadow-selected);
}

& .CounterLabel {
color: var(--button-primary-fgColor-rest) !important; /* temporarily override our own sx prop */
background-color: var(--buttonCounter-primary-bgColor-rest) !important; /* temporarily override our own sx prop */
Expand All @@ -335,6 +335,17 @@
background-color: var(--button-danger-bgColor-rest);
box-shadow: var(--button-default-shadow-resting);

&[aria-expanded='true'] {
color: var(--button-danger-fgColor-active);
background-color: var(--button-danger-bgColor-active);
border-color: var(--button-danger-borderColor-active);
box-shadow: var(--button-danger-shadow-selected);

& .Visual {
color: var(--button-danger-iconColor-hover);
}
}

&:hover {
color: var(--button-danger-fgColor-hover);
background-color: var(--button-danger-bgColor-hover);
Expand All @@ -361,6 +372,10 @@
color: var(--buttonCounter-danger-fgColor-hover) !important; /* temporarily override our own sx prop */
background-color: var(--buttonCounter-danger-bgColor-hover) !important;
}

& .Visual {
color: var(--button-danger-iconColor-hover);
}
}

&:disabled {
Expand All @@ -375,13 +390,6 @@
}
}

&[aria-expanded='true'] {
color: var(--button-danger-fgColor-active);
background-color: var(--button-danger-bgColor-active);
border-color: var(--button-danger-borderColor-active);
box-shadow: var(--button-danger-shadow-selected);
}

& .CounterLabel {
color: var(--buttonCounter-danger-fgColor-rest) !important; /* temporarily override our own sx prop */
background-color: var(--buttonCounter-danger-bgColor-rest) !important;
Expand All @@ -399,6 +407,10 @@
border-color: transparent;
box-shadow: none;

&[aria-expanded='true'] {
background-color: var(--button-invisible-bgColor-active);
}

&:hover {
background-color: var(--button-invisible-bgColor-hover);

Expand All @@ -422,10 +434,6 @@
box-shadow: none;
}

&[aria-expanded='true'] {
background-color: var(--button-invisible-bgColor-active);
}

& .Visual {
color: var(--button-invisible-iconColor-rest);
}
Expand Down
Loading