-
Notifications
You must be signed in to change notification settings - Fork 21
SplitButton needs label #154
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
Open
OjhaAditi25
wants to merge
12
commits into
microsoft:main
Choose a base branch
from
OjhaAditi25:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3669d45
SplitButton needs label
OjhaAditi25 1c2091d
Adding more test
OjhaAditi25 d854b46
Updating README.md
OjhaAditi25 527712f
Updating rule
OjhaAditi25 721fe66
Updating rule name to kebab case
OjhaAditi25 3d440ac
Updating README.md
OjhaAditi25 89ddea0
Merge branch 'main' into main
OjhaAditi25 e3ad83c
Merge branch 'main' into main
OjhaAditi25 cd6d850
Updating rule
OjhaAditi25 8b1e607
Updating doc
OjhaAditi25 46cb3f3
Updating rule to use with factory function
OjhaAditi25 9e86a66
Merge branch 'main' into main
OjhaAditi25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Accessibility: SplitButton must have an accessible name via title, aria-label (`@microsoft/fluentui-jsx-a11y/split-button-needs-labelling`) | ||
|
|
||
| 💼 This rule is enabled in the ✅ `recommended` config. | ||
|
|
||
| <!-- end auto-generated rule header --> | ||
|
|
||
| SplitButton without a label or accessible labeling lack an accessible name for assistive technology users. | ||
|
|
||
| SplitButton components need a visual label. | ||
|
|
||
| Please add label, or aria-labelledby. | ||
|
|
||
| <https://www.w3.org/WAI/standards-guidelines/act/rules/97a4e1/> | ||
|
|
||
| ## Rule Details | ||
|
|
||
| This rule aims to... | ||
|
|
||
| Examples of **incorrect** code for this rule: | ||
|
|
||
| ```jsx | ||
| <SplitButton> Example</SplitButton> | ||
| ``` | ||
|
|
||
| ```jsx | ||
| <SplitButton disabled> Example</SplitButton> | ||
| ``` | ||
|
|
||
|
|
||
| Examples of **correct** code for this rule: | ||
|
|
||
| ```jsx | ||
| <SplitButton aria-label="My button">Example</SplitButton> | ||
| ``` | ||
|
|
||
| ```jsx | ||
| <SplitButton disabled aria-label="My button">Disabled State</SplitButton> | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { ESLintUtils } from "@typescript-eslint/utils"; | ||
| import { makeLabeledControlRule } from "../util/ruleFactory"; | ||
|
|
||
| //------------------------------------------------------------------------------ | ||
| // Rule Definition | ||
| //------------------------------------------------------------------------------ | ||
|
|
||
| export default ESLintUtils.RuleCreator.withoutDocs( | ||
| makeLabeledControlRule({ | ||
| component: "SplitButton", | ||
| messageId: "noUnlabeledSplitButton", | ||
| description: "Accessibility: SplitButton must have an accessible name via title, aria-label", | ||
| labelProps: ["aria-label"], | ||
| allowFieldParent: true, | ||
| allowHtmlFor: false, | ||
| allowLabelledBy: true, | ||
| allowWrappingLabel: false, | ||
| allowTooltipParent: false, | ||
| allowDescribedBy: false, | ||
| allowLabeledChild: false | ||
| }) | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { Rule } from "eslint"; | ||
| import ruleTester from "./helper/ruleTester"; | ||
| import rule from "../../../lib/rules/split-button-needs-labelling"; | ||
| // ----------------------------------------------------------------------------- | ||
| // Tests | ||
| // ----------------------------------------------------------------------------- | ||
|
|
||
| ruleTester.run("split-button-needs-labelling", rule as unknown as Rule.RuleModule, { | ||
| valid: [ | ||
| // 1) aria-label on the SplitButton | ||
|
|
||
| `<SplitButton aria-label="Example">Example</SplitButton> | ||
| `, | ||
| // 2) disabled SplitButton with aria-label | ||
| ` | ||
| <SplitButton aria-label="Example" disabled> Disabled State </SplitButton> | ||
| `, | ||
| `<> | ||
| <span id="splitButton">Choose Values</span> | ||
| <SplitButton aria-labelledby="splitButton"> Example | ||
| </SplitButton> | ||
| </>` | ||
| ], | ||
|
|
||
| invalid: [ | ||
| // Unlabeled SplitButton | ||
| { | ||
| code: ` | ||
| <SplitButton>Example</SplitButton> | ||
| `, | ||
| errors: [{ messageId: "noUnlabeledSplitButton" }] | ||
| }, | ||
| // disabled SplitButton without aria-label | ||
| { | ||
| code: ` | ||
| <SplitButton disabled>Example</SplitButton> | ||
| `, | ||
| errors: [{ messageId: "noUnlabeledSplitButton" }] | ||
| }, | ||
| // SplitButton with empty aria-label | ||
| { | ||
| code: ` | ||
| <SplitButton aria-label="">Example</SplitButton> | ||
| `, | ||
| errors: [{ messageId: "noUnlabeledSplitButton" }] | ||
| }, | ||
| // SplitButton with aria-label undefined | ||
| { | ||
| code: ` | ||
| <SplitButton aria-label={undefined}>Example</SplitButton> | ||
| `, | ||
| errors: [{ messageId: "noUnlabeledSplitButton" }] | ||
| }, | ||
| // SplitButton with aria-label null | ||
| { | ||
| code: ` | ||
| <SplitButton aria-label={null}>Example</SplitButton> | ||
| `, | ||
| errors: [{ messageId: "noUnlabeledSplitButton" }] | ||
| } | ||
| ] | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is actually valid