Skip to content

Commit

Permalink
Fix primefaces#1432: Carousel accessible buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed May 2, 2022
1 parent 91875ae commit e330ffd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
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

0 comments on commit e330ffd

Please sign in to comment.