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 #1432: Carousel accessible buttons #2826

Merged
merged 1 commit into from
May 2, 2022
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: 4 additions & 1 deletion components/lib/api/Locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ let locales = {
aria: {
trueLabel: 'True',
falseLabel: 'False',
nullLabel: 'Not Selected'
nullLabel: 'Not Selected',
pageLabel: 'Page',
nextPageLabel: 'Next Page',
previousPageLabel: 'Previous Page'
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion components/lib/button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const Button = React.memo(React.forwardRef((props, ref) => {
const icon = createIcon();
const label = createLabel();
const badge = createBadge();
const defaultAriaLabel = (props.label ? props.label + (props.badge ? ' ' + props.badge : '') : '');
const defaultAriaLabel = (props.label ? props.label + (props.badge ? ' ' + props.badge : '') : props['aria-label']);

return (
<>
Expand Down
17 changes: 5 additions & 12 deletions components/lib/carousel/Carousel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import PrimeReact from '../api/Api';
import { ariaLabel } from '../api/Api';
import { Button } from '../button/Button';
import { useMountEffect, usePrevious, useResizeListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { Ripple } from '../ripple/Ripple';
import { classNames, DomHandler, ObjectUtils, UniqueComponentId } from '../utils/Utils';

const CarouselItem = React.memo((props) => {
Expand Down Expand Up @@ -486,10 +487,7 @@ export const Carousel = React.memo(React.forwardRef((props, ref) => {
});

return (
<button type="button" className={className} onClick={navBackward} disabled={isDisabled}>
<span className={iconClassName}></span>
<Ripple />
</button>
<Button className={className} icon={iconClassName} onClick={navBackward} disabled={isDisabled} aria-label={ariaLabel('previousPageLabel')} />
)
}

Expand All @@ -504,10 +502,7 @@ export const Carousel = React.memo(React.forwardRef((props, ref) => {
});

return (
<button type="button" className={className} onClick={navForward} disabled={isDisabled}>
<span className={iconClassName}></span>
<Ripple />
</button>
<Button className={className} icon={iconClassName} onClick={navForward} disabled={isDisabled} aria-label={ariaLabel('nextPageLabel')} />
)
}

Expand All @@ -520,9 +515,7 @@ export const Carousel = React.memo(React.forwardRef((props, ref) => {

return (
<li key={key} className={className}>
<button type="button" className="p-link" onClick={(e) => onDotClick(e, index)}>
<Ripple />
</button>
<Button className="p-link" onClick={(e) => onDotClick(e, index)} aria-label={`${ariaLabel('pageLabel')} ${index + 1}`} />
</li>
)
}
Expand Down