Skip to content

Commit fc03836

Browse files
fix: focus styles for env headers (#9635)
Adds focus styles to the env accordion header only when the focus is on the header itself (not on the env toggle inside the header). The focus style is consistent with what we do for other accordions (dashboard, milestones). Middle one is focused: ![image](https://github.com/user-attachments/assets/df87bd99-8fe2-4093-afd8-4cbce9f2c943) Focus is on the toggle inside the top one (yeh, we should have better focus styles for toggles; but that's not for now): ![image](https://github.com/user-attachments/assets/2a046d4c-8585-4021-a58e-32ef81b1f701) Open and focused: ![image](https://github.com/user-attachments/assets/fdbb5bda-4be5-4354-b213-5e2c7a59eb59) Getting the consistent background for the header when it's open is a little tricky because the accordion container and summary are split into different files. ~~This first iteration used a class name for the specific header (because envs can have multiple accordion headers inside them, e.g. release plans) and setting a CSS variable in the summary, so that the background matches.~~ I found out that I only need to set it in the parent anyway 😄 Without it, you get this (notice that there is a little white outside the lower corners): ![image](https://github.com/user-attachments/assets/4d71d73c-7f45-46b5-811d-c6e36f9be5ce)
1 parent 14c8b97 commit fc03836

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

frontend/src/component/common/NewConstraintAccordion/ConstraintAccordionView/ConstraintAccordionView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const ConstraintAccordionView = ({
9595
cursor: expandable ? 'pointer' : 'default!important',
9696
},
9797
}}
98+
tabIndex={expandable ? 0 : -1}
9899
>
99100
<StyledWrapper>
100101
<ConstraintAccordionViewHeader

frontend/src/component/common/StrategyItemContainer/StrategyItemContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const StrategyItemContainer: FC<StrategyItemContainerProps> = ({
9696
<StyledHeader disabled={Boolean(strategy?.disabled)}>
9797
{onDragStart ? (
9898
<DragIcon
99+
tabIndex={-1}
99100
className='strategy-drag-handle'
100101
draggable
101102
disableRipple

frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentHeader/EnvironmentHeader.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@ const StyledAccordionSummary = styled(AccordionSummary, {
1717
padding: theme.spacing(0.5, 3, 0.5, 2),
1818
display: 'flex',
1919
alignItems: 'center',
20+
borderRadius: theme.shape.borderRadiusLarge,
21+
pointerEvents: 'auto',
22+
opacity: 1,
2023
'&&&': {
2124
cursor: expandable ? 'pointer' : 'default',
2225
},
26+
27+
':focus-within': {
28+
background: 'none',
29+
},
2330
}));
2431

2532
const StyledHeader = styled('header')(({ theme }) => ({
@@ -108,6 +115,9 @@ const MetadataChip = ({
108115
return <StyledStrategyCount>{text}</StyledStrategyCount>;
109116
};
110117

118+
export const environmentAccordionSummaryClassName =
119+
'environment-accordion-summary';
120+
111121
export const EnvironmentHeader: FC<
112122
PropsWithChildren<EnvironmentHeaderProps>
113123
> = ({
@@ -129,6 +139,8 @@ export const EnvironmentHeader: FC<
129139
id={id}
130140
aria-controls={`environment-accordion-${id}-content`}
131141
expandable={expandable}
142+
tabIndex={expandable ? 0 : -1}
143+
className={environmentAccordionSummaryClassName}
132144
>
133145
<StyledHeader data-loading>
134146
<StyledHeaderTitle>

frontend/src/component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/FeatureOverviewEnvironment.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import { FEATURE_ENVIRONMENT_ACCORDION } from 'utils/testIds';
88
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
99
import { UpgradeChangeRequests } from './UpgradeChangeRequests/UpgradeChangeRequests';
1010
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
11-
import { EnvironmentHeader } from './EnvironmentHeader/EnvironmentHeader';
11+
import {
12+
environmentAccordionSummaryClassName,
13+
EnvironmentHeader,
14+
} from './EnvironmentHeader/EnvironmentHeader';
1215
import FeatureOverviewEnvironmentMetrics from './EnvironmentHeader/FeatureOverviewEnvironmentMetrics/FeatureOverviewEnvironmentMetrics';
1316
import { FeatureOverviewEnvironmentToggle } from './EnvironmentHeader/FeatureOverviewEnvironmentToggle/FeatureOverviewEnvironmentToggle';
1417
import { useState } from 'react';
@@ -26,11 +29,8 @@ const StyledFeatureOverviewEnvironment = styled('div')(({ theme }) => ({
2629
const StyledAccordion = styled(Accordion)(({ theme }) => ({
2730
boxShadow: 'none',
2831
background: 'none',
29-
'&&& .MuiAccordionSummary-root': {
30-
borderRadius: theme.shape.borderRadiusLarge,
31-
pointerEvents: 'auto',
32-
opacity: 1,
33-
backgroundColor: theme.palette.background.paper,
32+
[`&:has(.${environmentAccordionSummaryClassName}:focus-visible)`]: {
33+
background: theme.palette.table.headerHover,
3434
},
3535
}));
3636

@@ -85,7 +85,6 @@ export const FeatureOverviewEnvironment = ({
8585
TransitionProps={{ mountOnEnter: true, unmountOnExit: true }}
8686
data-testid={`${FEATURE_ENVIRONMENT_ACCORDION}_${environment.name}`}
8787
expanded={isOpen && hasActivations}
88-
disabled={!hasActivations}
8988
onChange={() => {
9089
const state = isOpen ? !isOpen : hasActivations;
9190
onToggleEnvOpen(state);

frontend/src/component/feature/FeatureView/FeatureOverview/ReleasePlan/ReleasePlan.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ import { StartMilestoneChangeRequestDialog } from './ChangeRequest/StartMileston
2424
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
2525
import { Truncator } from 'component/common/Truncator/Truncator';
2626

27-
const StyledContainer = styled('div', {
28-
shouldForwardProp: (prop) => prop !== 'readonly',
29-
})<{ readonly?: boolean }>(({ theme, readonly }) => ({
27+
const StyledContainer = styled('div')(({ theme }) => ({
3028
padding: theme.spacing(2),
3129
paddingTop: theme.spacing(0),
3230
background: 'inherit',
@@ -235,7 +233,7 @@ export const ReleasePlan = ({
235233
);
236234

237235
return (
238-
<StyledContainer readonly={readonly}>
236+
<StyledContainer>
239237
<StyledHeader>
240238
<StyledHeaderGroup>
241239
<StyledHeaderTitleLabel>

0 commit comments

Comments
 (0)