Skip to content

Commit

Permalink
Merge pull request #8417 from CitizenLabDotCo/fix-missing-aria-label
Browse files Browse the repository at this point in the history
TAN-2283: Fix missing aria label on horizontal scroll
  • Loading branch information
EdwinKato authored Jul 22, 2024
2 parents 2edb513 + c1b2c1a commit 01be73f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions front/app/components/HorizontalScroll/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import {
} from '@citizenlab/cl2-component-library';
import styled, { useTheme } from 'styled-components';

import { useIntl } from 'utils/cl-intl';

import messages from './messages';

const StyledContainer = styled(Box)`
display: flex;
gap: 16px;
Expand Down Expand Up @@ -43,6 +47,7 @@ interface Props {
const HorizontalScroll = ({ children, containerRole }: Props) => {
const theme = useTheme();
const isSmallerThanPhone = useBreakpoint('phone');
const { formatMessage } = useIntl();
const containerRef = React.useRef<HTMLDivElement>(null);
// Used to determine when the scroll buttons should be disabled (E.g. At scroll end, disable the right button)
const [atScrollStart, setAtScrollStart] = useState(true);
Expand Down Expand Up @@ -100,6 +105,7 @@ const HorizontalScroll = ({ children, containerRole }: Props) => {
p="0px"
my="auto"
className="e2e-event-previews-scroll-left"
ariaLabel={formatMessage(messages.scrollLeftLabel)}
/>
</Box>
<StyledContainer ref={containerRef} role={containerRole}>
Expand All @@ -119,6 +125,7 @@ const HorizontalScroll = ({ children, containerRole }: Props) => {
buttonStyle="text"
p="0px"
className="e2e-event-previews-scroll-right"
ariaLabel={formatMessage(messages.scrollRightLabel)}
/>
</Box>
</Box>
Expand Down
12 changes: 12 additions & 0 deletions front/app/components/HorizontalScroll/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineMessages } from 'react-intl';

export default defineMessages({
scrollLeftLabel: {
id: 'app.components.HorizontalScroll.scrollLeftLabel',
defaultMessage: 'Scroll left.',
},
scrollRightLabel: {
id: 'app.components.HorizontalScroll.scrollRightLabel',
defaultMessage: 'Scroll right.',
},
});
2 changes: 2 additions & 0 deletions front/app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@
"app.components.HookForm.Feedback.submissionError": "Try again. If the issue persists, contact us",
"app.components.HookForm.Feedback.submissionErrorTitle": "There was a problem on our end, sorry",
"app.components.HookForm.Feedback.successMessage": "Form successfully submitted",
"app.components.HorizontalScroll.scrollLeftLabel": "Scroll left.",
"app.components.HorizontalScroll.scrollRightLabel": "Scroll right.",
"app.components.IdeaCards.a11y_ideasHaveBeenSorted": "{sortOder} ideas have loaded.",
"app.components.IdeaCards.showMore": "Show more",
"app.components.IdeasMap.a11y_hideIdeaCard": "Hide idea card.",
Expand Down

0 comments on commit 01be73f

Please sign in to comment.