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

feat: add aria-pressed prop to IconButton #2428

Merged
merged 1 commit into from
Sep 11, 2024
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
11 changes: 9 additions & 2 deletions packages/core/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export interface ButtonProps extends VibeComponentProps {
* aria to be used for screen reader to know if the button is hidden
*/
"aria-hidden"?: AriaAttributes["aria-hidden"];
/**
* Indicates the current "pressed" state of toggle buttons
*/
"aria-pressed"?: AriaAttributes["aria-pressed"];
/** On Button Focus callback */
onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
/** On Button Blur callback */
Expand Down Expand Up @@ -144,6 +148,7 @@ const Button: VibeComponent<ButtonProps, unknown> & {
ariaControls,
"aria-describedby": ariaDescribedBy,
"aria-hidden": ariaHidden,
"aria-pressed": ariaPressed,
blurOnMouseUp,
dataTestId: backwardCompatabilityDataTestId,
"data-testid": dataTestId,
Expand Down Expand Up @@ -269,7 +274,8 @@ const Button: VibeComponent<ButtonProps, unknown> & {
"aria-expanded": ariaExpanded,
"aria-controls": ariaControls,
"aria-describedby": ariaDescribedBy,
"aria-hidden": ariaHidden
"aria-hidden": ariaHidden,
"aria-pressed": ariaPressed
};
return props;
}, [
Expand All @@ -294,7 +300,8 @@ const Button: VibeComponent<ButtonProps, unknown> & {
ariaExpanded,
ariaControls,
ariaDescribedBy,
ariaHidden
ariaHidden,
ariaPressed
]);

const leftIconSize = useMemo(() => {
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/components/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export interface IconButtonProps extends VibeComponentProps {
* a11y property to be added, used for screen reader to know if the button is hidden
*/
"aria-hidden"?: AriaAttributes["aria-hidden"];
/**
* Indicates the current "pressed" state of toggle buttons
*/
"aria-pressed"?: AriaAttributes["aria-pressed"];
/**
* Size of the icon
*/
Expand Down Expand Up @@ -126,6 +130,7 @@ const IconButton: VibeComponent<IconButtonProps> & {
ariaControls,
"aria-describedby": ariaDescribedBy,
"aria-hidden": ariaHidden,
"aria-pressed": ariaPressed,
hideTooltip = false,
kind = IconButton.kinds.TERTIARY,
active,
Expand Down Expand Up @@ -214,6 +219,7 @@ const IconButton: VibeComponent<IconButtonProps> & {
ariaControls={ariaControls}
aria-describedby={ariaDescribedBy}
aria-hidden={ariaHidden}
aria-pressed={ariaPressed}
ref={mergedRef}
id={id}
data-testid={overrideDataTestId || getTestId(ComponentDefaultTestId.ICON_BUTTON, id)}
Expand Down