Skip to content

Conversation

@OjhaAditi25
Copy link
Collaborator

Added new rule for SplitButton to have an accessible name

Issue- #45

@OjhaAditi25 OjhaAditi25 self-assigned this Sep 17, 2025
@OjhaAditi25 OjhaAditi25 added the bug Something isn't working label Sep 17, 2025
@OjhaAditi25 OjhaAditi25 marked this pull request as draft September 17, 2025 11:27
@OjhaAditi25 OjhaAditi25 marked this pull request as ready for review September 18, 2025 09:55
// Unlabeled SplitButton
{
code: `
<SplitButton>Example</SplitButton>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is actually valid

Copy link
Collaborator

@aubreyquinn aubreyquinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SplitButton component is a unique type of a button. Here are the valid ways to have an accessible SplitButton:

  1. It has text content. If it has any text content at all, then it is accessible even if it has an icon.

e.g.
<SplitButton
menuButton={triggerProps}
primaryActionButton={primaryActionButtonProps}
icon={}
>
Example

    <SplitButton
      menuButton={triggerProps}
      primaryActionButton={primaryActionButtonProps}
    >
      Example
    </SplitButton>
  1. If it does not have text content, then we must label the primary action button and not the SplitButton itself.

           <SplitButton
             menuButton={triggerProps}
             primaryActionButton={{
               ref: setPrimaryActionButtonRef,
               "aria-label": "With calendar icon only",
             }}
             icon={<CalendarMonthRegular />}
           />
    

We would need to adjust our ruleFactory to take in a custom checker function.

aria-label, aria-labelledby, htmlFor, aria-describedby, Label, Field and Tooltip are not valid ways to label the SplitButton.

@OjhaAditi25
Copy link
Collaborator Author

The SplitButton component is a unique type of a button. Here are the valid ways to have an accessible SplitButton:

  1. It has text content. If it has any text content at all, then it is accessible even if it has an icon.

e.g. Example

    <SplitButton
      menuButton={triggerProps}
      primaryActionButton={primaryActionButtonProps}
    >
      Example
    </SplitButton>
  1. If it does not have text content, then we must label the primary action button and not the SplitButton itself.
           <SplitButton
             menuButton={triggerProps}
             primaryActionButton={{
               ref: setPrimaryActionButtonRef,
               "aria-label": "With calendar icon only",
             }}
             icon={<CalendarMonthRegular />}
           />
    

We would need to adjust our ruleFactory to take in a custom checker function.

aria-label, aria-labelledby, htmlFor, aria-describedby, Label, Field and Tooltip are not valid ways to label the SplitButton.

Thank you @aubreyquinn. I have updated rule accordingly.
I didn't update/use factory function, may be if its okay I will handle it separately.

@OjhaAditi25
Copy link
Collaborator Author

The SplitButton component is a unique type of a button. Here are the valid ways to have an accessible SplitButton:

  1. It has text content. If it has any text content at all, then it is accessible even if it has an icon.

e.g. Example

    <SplitButton
      menuButton={triggerProps}
      primaryActionButton={primaryActionButtonProps}
    >
      Example
    </SplitButton>
  1. If it does not have text content, then we must label the primary action button and not the SplitButton itself.
           <SplitButton
             menuButton={triggerProps}
             primaryActionButton={{
               ref: setPrimaryActionButtonRef,
               "aria-label": "With calendar icon only",
             }}
             icon={<CalendarMonthRegular />}
           />
    

We would need to adjust our ruleFactory to take in a custom checker function.
aria-label, aria-labelledby, htmlFor, aria-describedby, Label, Field and Tooltip are not valid ways to label the SplitButton.

Thank you @aubreyquinn. I have updated rule accordingly. I didn't update/use factory function, may be if its okay I will handle it separately.

Updated to use factory rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants