Skip to content
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

fix(addon-a11y): Addon-a11y displays visual bug when running the tests #29552

Merged
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
60 changes: 27 additions & 33 deletions code/addons/a11y/src/components/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,21 @@ const HighlightToggleLabel = styled.label(({ theme }) => ({
color: theme.color.dark,
}));

const GlobalToggle = styled.div<{ elementWidth: number }>(({ elementWidth, theme }) => {
const maxWidthBeforeBreak = 450;
return {
cursor: 'pointer',
fontSize: 13,
lineHeight: '20px',
padding: elementWidth > maxWidthBeforeBreak ? '10px 15px 10px 0' : '10px 0px 10px 15px',
height: '40px',
border: 'none',
marginTop: elementWidth > maxWidthBeforeBreak ? -40 : 0,
float: elementWidth > maxWidthBeforeBreak ? 'right' : 'left',
display: 'flex',
alignItems: 'center',
width: elementWidth > maxWidthBeforeBreak ? 'auto' : '100%',
borderBottom: elementWidth > maxWidthBeforeBreak ? 'none' : `1px solid ${theme.appBorderColor}`,

input: {
marginLeft: 10,
marginRight: 0,
marginTop: -1,
marginBottom: 0,
},
};
});
const GlobalToggle = styled.div(() => ({
alignItems: 'center',
cursor: 'pointer',
display: 'flex',
fontSize: 13,
height: 40,
padding: '0 15px',

input: {
marginBottom: 0,
marginLeft: 10,
marginRight: 0,
marginTop: -1,
},
}));

const Item = styled.button<{ active?: boolean }>(
({ theme }) => ({
Expand Down Expand Up @@ -82,6 +73,7 @@ const List = styled.div(({ theme }) => ({
boxShadow: `${theme.appBorderColor} 0 -1px 0 0 inset`,
background: theme.background.app,
display: 'flex',
flexWrap: 'wrap',
justifyContent: 'space-between',
whiteSpace: 'nowrap',
}));
Expand Down Expand Up @@ -131,16 +123,18 @@ export const Tabs: React.FC<TabsProps> = ({ tabs }) => {
</Item>
))}
</TabsWrapper>
{tabs[activeTab].items.length > 0 ? (
<GlobalToggle>
<HighlightToggleLabel htmlFor={highlightToggleId}>
{highlightLabel}
</HighlightToggleLabel>
<HighlightToggle
toggleId={highlightToggleId}
elementsToHighlight={retrieveAllNodesFromResults(tabs[activeTab].items)}
/>
</GlobalToggle>
) : null}
</List>
{tabs[activeTab].items.length > 0 ? (
<GlobalToggle elementWidth={width || 0}>
<HighlightToggleLabel htmlFor={highlightToggleId}>{highlightLabel}</HighlightToggleLabel>
<HighlightToggle
toggleId={highlightToggleId}
elementsToHighlight={retrieveAllNodesFromResults(tabs[activeTab].items)}
/>
</GlobalToggle>
) : null}
{tabs[activeTab].panel}
</Container>
);
Expand Down