diff --git a/eslint.config.mjs b/eslint.config.mjs index 5432418886..661d386b9e 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,6 +1,7 @@ // @ts-check import pluginImport from 'eslint-plugin-import'; +import pluginJsxA11y from 'eslint-plugin-jsx-a11y'; import * as mdx from 'eslint-plugin-mdx'; import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; import pluginReact from 'eslint-plugin-react'; @@ -450,7 +451,18 @@ export default tseslint.config( }, }, { - plugins: { 'react': pluginReact, 'react-hooks': pluginReactHooks }, + plugins: { + 'jsx-a11y': pluginJsxA11y, + }, + rules: { + ...pluginJsxA11y.configs.recommended.rules, + }, + }, + { + plugins: { + 'react': pluginReact, + 'react-hooks': pluginReactHooks, + }, languageOptions: { globals: { ...globals.browser, diff --git a/package.json b/package.json index ea22a6318c..daf2f31d17 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "eslint": "~9.14.0", "eslint-import-resolver-typescript": "~3.7.0", "eslint-plugin-import": "~2.31.0", + "eslint-plugin-jsx-a11y": "~6.10.2", "eslint-plugin-mdx": "~3.1.5", "eslint-plugin-prettier": "~5.2.1", "eslint-plugin-react": "~7.37.2", diff --git a/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx b/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx index 650e35b0f6..2925f1cf31 100644 --- a/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx +++ b/packages/fuselage/src/components/AudioPlayer/AudioPlayer.tsx @@ -1,4 +1,5 @@ import { useMergedRefs, useResizeObserver } from '@rocket.chat/fuselage-hooks'; +import type { TrackHTMLAttributes } from 'react'; import { useState, useRef, forwardRef } from 'react'; import { Box, Button, IconButton, Margins } from '../..'; @@ -57,22 +58,22 @@ const getDurationForInfinityDurationAudioFile = ( /** * A Fuselage’s custom AudioPlayer. */ -export const AudioPlayer = forwardRef< - HTMLAudioElement, - { - src: string; - type?: string; - maxPlaybackSpeed?: number; - minPlaybackSpeed?: number; - playbackSpeedStep?: number; - download?: boolean; - playLabel?: string; - pauseLabel?: string; - audioPlaybackRangeLabel?: string; - changePlaybackSpeedLabel?: string; - downloadAudioFileLabel?: string; - } ->( +type AudioPlayerProps = { + src: string; + type?: string; + maxPlaybackSpeed?: number; + minPlaybackSpeed?: number; + playbackSpeedStep?: number; + download?: boolean; + playLabel?: string; + pauseLabel?: string; + audioPlaybackRangeLabel?: string; + changePlaybackSpeedLabel?: string; + downloadAudioFileLabel?: string; + trackProps?: TrackHTMLAttributes; +}; + +export const AudioPlayer = forwardRef( ( { src, @@ -86,6 +87,7 @@ export const AudioPlayer = forwardRef< audioPlaybackRangeLabel = 'Audio Playback Range', changePlaybackSpeedLabel = 'Change Playback Speed', downloadAudioFileLabel = 'Download Audio File', + trackProps, }, ref, ) => { @@ -222,6 +224,7 @@ export const AudioPlayer = forwardRef< controls > + ); diff --git a/packages/fuselage/src/components/AutoComplete/__snapshots__/AutoComplete.spec.tsx.snap b/packages/fuselage/src/components/AutoComplete/__snapshots__/AutoComplete.spec.tsx.snap index 453f640da8..2617a99b3e 100644 --- a/packages/fuselage/src/components/AutoComplete/__snapshots__/AutoComplete.spec.tsx.snap +++ b/packages/fuselage/src/components/AutoComplete/__snapshots__/AutoComplete.spec.tsx.snap @@ -53,6 +53,7 @@ exports[`[AutoComplete Rendering] renders CustomSelected without crashing 1`] = class="rcx-box rcx-box--full rcx-avatar rcx-avatar--x20" > diff --git a/packages/fuselage/src/components/Sidebar/SidebarBanner.tsx b/packages/fuselage/src/components/Sidebar/SidebarBanner.tsx index 33738055a1..8c350863f9 100644 --- a/packages/fuselage/src/components/Sidebar/SidebarBanner.tsx +++ b/packages/fuselage/src/components/Sidebar/SidebarBanner.tsx @@ -30,6 +30,8 @@ export const SidebarBanner = ({ {text &&
{text}
} {description && (
e.key === 'Enter' && onClick?.()} > {description}
diff --git a/packages/fuselage/src/components/SidebarV2/SidebarBanner.tsx b/packages/fuselage/src/components/SidebarV2/SidebarBanner.tsx index df2af569b9..e8edd4e9c0 100644 --- a/packages/fuselage/src/components/SidebarV2/SidebarBanner.tsx +++ b/packages/fuselage/src/components/SidebarV2/SidebarBanner.tsx @@ -38,7 +38,6 @@ export const SidebarBanner = ({ {linkText && ( {linkText} diff --git a/packages/fuselage/src/components/SidebarV2/SidebarLink.tsx b/packages/fuselage/src/components/SidebarV2/SidebarLink.tsx index ad64039fec..94904d2a03 100644 --- a/packages/fuselage/src/components/SidebarV2/SidebarLink.tsx +++ b/packages/fuselage/src/components/SidebarV2/SidebarLink.tsx @@ -18,6 +18,8 @@ export const SidebarLink = ({ menu?: ReactNode; } & LinkHTMLAttributes) => ( e.stopPropagation()} + onKeyDown={(e) => e.code === 'Enter' && e.stopPropagation()} {...props} > {icon && ( diff --git a/yarn.lock b/yarn.lock index 178c02b0dd..db89e8a259 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4592,6 +4592,7 @@ __metadata: eslint: "npm:~9.14.0" eslint-import-resolver-typescript: "npm:~3.7.0" eslint-plugin-import: "npm:~2.31.0" + eslint-plugin-jsx-a11y: "npm:~6.10.2" eslint-plugin-mdx: "npm:~3.1.5" eslint-plugin-prettier: "npm:~5.2.1" eslint-plugin-react: "npm:~7.37.2" @@ -7449,6 +7450,13 @@ __metadata: languageName: node linkType: hard +"aria-query@npm:^5.3.2": + version: 5.3.2 + resolution: "aria-query@npm:5.3.2" + checksum: 10/b2fe9bc98bd401bc322ccb99717c1ae2aaf53ea0d468d6e7aebdc02fac736e4a99b46971ee05b783b08ade23c675b2d8b60e4a1222a95f6e27bc4d2a0bfdcc03 + languageName: node + linkType: hard + "array-buffer-byte-length@npm:^1.0.1": version: 1.0.1 resolution: "array-buffer-byte-length@npm:1.0.1" @@ -7459,7 +7467,7 @@ __metadata: languageName: node linkType: hard -"array-includes@npm:^3.1.5, array-includes@npm:^3.1.8": +"array-includes@npm:^3.1.5, array-includes@npm:^3.1.6, array-includes@npm:^3.1.8": version: 3.1.8 resolution: "array-includes@npm:3.1.8" dependencies: @@ -7508,7 +7516,7 @@ __metadata: languageName: node linkType: hard -"array.prototype.flat@npm:^1.3.2": +"array.prototype.flat@npm:^1.3.1, array.prototype.flat@npm:^1.3.2": version: 1.3.2 resolution: "array.prototype.flat@npm:1.3.2" dependencies: @@ -7597,6 +7605,13 @@ __metadata: languageName: node linkType: hard +"ast-types-flow@npm:^0.0.8": + version: 0.0.8 + resolution: "ast-types-flow@npm:0.0.8" + checksum: 10/85a1c24af4707871c27cfe456bd2ff7fcbe678f3d1c878ac968c9557735a171a17bdcc8c8f903ceab3fc3c49d5b3da2194e6ab0a6be7fec0e133fa028f21ba1b + languageName: node + linkType: hard + "ast-types@npm:^0.16.1": version: 0.16.1 resolution: "ast-types@npm:0.16.1" @@ -7689,6 +7704,20 @@ __metadata: languageName: node linkType: hard +"axe-core@npm:^4.10.0": + version: 4.10.2 + resolution: "axe-core@npm:4.10.2" + checksum: 10/a69423b2ff16c15922c4ea7cf9cc5112728a2817bbe0f2cc212248d648885ffd1ba554e3a341dfc289cd9e67fc0d06f333b5c6837c5c38ca6652507381216fc1 + languageName: node + linkType: hard + +"axobject-query@npm:^4.1.0": + version: 4.1.0 + resolution: "axobject-query@npm:4.1.0" + checksum: 10/e275dea9b673f71170d914f2d2a18be5d57d8d29717b629e7fedd907dcc2ebdc7a37803ff975874810bd423f222f299c020d28fde40a146f537448bf6bfecb6e + languageName: node + linkType: hard + "b4a@npm:^1.6.4": version: 1.6.4 resolution: "b4a@npm:1.6.4" @@ -9183,6 +9212,13 @@ __metadata: languageName: node linkType: hard +"damerau-levenshtein@npm:^1.0.8": + version: 1.0.8 + resolution: "damerau-levenshtein@npm:1.0.8" + checksum: 10/f4eba1c90170f96be25d95fa3857141b5f81e254f7e4d530da929217b19990ea9a0390fc53d3c1cafac9152fda78e722ea4894f765cf6216be413b5af1fbf821 + languageName: node + linkType: hard + "dashdash@npm:^1.12.0": version: 1.14.1 resolution: "dashdash@npm:1.14.1" @@ -10200,6 +10236,31 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-jsx-a11y@npm:~6.10.2": + version: 6.10.2 + resolution: "eslint-plugin-jsx-a11y@npm:6.10.2" + dependencies: + aria-query: "npm:^5.3.2" + array-includes: "npm:^3.1.8" + array.prototype.flatmap: "npm:^1.3.2" + ast-types-flow: "npm:^0.0.8" + axe-core: "npm:^4.10.0" + axobject-query: "npm:^4.1.0" + damerau-levenshtein: "npm:^1.0.8" + emoji-regex: "npm:^9.2.2" + hasown: "npm:^2.0.2" + jsx-ast-utils: "npm:^3.3.5" + language-tags: "npm:^1.0.9" + minimatch: "npm:^3.1.2" + object.fromentries: "npm:^2.0.8" + safe-regex-test: "npm:^1.0.3" + string.prototype.includes: "npm:^2.0.1" + peerDependencies: + eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9 + checksum: 10/388550798548d911e2286d530a29153ca00434a06fcfc0e31e0dda46a5e7960005e532fb29ce1ccbf1e394a3af3e5cf70c47ca43778861eacc5e3ed799adb79c + languageName: node + linkType: hard + "eslint-plugin-markdown@npm:^3.0.1": version: 3.0.1 resolution: "eslint-plugin-markdown@npm:3.0.1" @@ -13305,6 +13366,18 @@ __metadata: languageName: node linkType: hard +"jsx-ast-utils@npm:^3.3.5": + version: 3.3.5 + resolution: "jsx-ast-utils@npm:3.3.5" + dependencies: + array-includes: "npm:^3.1.6" + array.prototype.flat: "npm:^1.3.1" + object.assign: "npm:^4.1.4" + object.values: "npm:^1.1.6" + checksum: 10/b61d44613687dfe4cc8ad4b4fbf3711bf26c60b8d5ed1f494d723e0808415c59b24a7c0ed8ab10736a40ff84eef38cbbfb68b395e05d31117b44ffc59d31edfc + languageName: node + linkType: hard + "keyv@npm:^4.5.4": version: 4.5.4 resolution: "keyv@npm:4.5.4" @@ -13372,6 +13445,22 @@ __metadata: languageName: node linkType: hard +"language-subtag-registry@npm:^0.3.20": + version: 0.3.23 + resolution: "language-subtag-registry@npm:0.3.23" + checksum: 10/fe13ed74ab9f862db8e5747b98cc9aa08d52a19f85b5cdb4975cd364c8539bd2da3380e4560d2dbbd728ec33dff8a4b4421fcb2e5b1b1bdaa21d16f91a54d0d4 + languageName: node + linkType: hard + +"language-tags@npm:^1.0.9": + version: 1.0.9 + resolution: "language-tags@npm:1.0.9" + dependencies: + language-subtag-registry: "npm:^0.3.20" + checksum: 10/d3a7c14b694e67f519153d6df6cb200681648d38d623c3bfa9d6a66a5ec5493628acb88e9df5aceef3cf1902ab263a205e7d59ee4cf1d6bb67e707b83538bd6d + languageName: node + linkType: hard + "leven@npm:^3.1.0": version: 3.1.0 resolution: "leven@npm:3.1.0" @@ -15290,7 +15379,7 @@ __metadata: languageName: node linkType: hard -"object.values@npm:^1.1.0, object.values@npm:^1.2.0": +"object.values@npm:^1.1.0, object.values@npm:^1.1.6, object.values@npm:^1.2.0": version: 1.2.0 resolution: "object.values@npm:1.2.0" dependencies: @@ -18239,6 +18328,17 @@ __metadata: languageName: node linkType: hard +"string.prototype.includes@npm:^2.0.1": + version: 2.0.1 + resolution: "string.prototype.includes@npm:2.0.1" + dependencies: + call-bind: "npm:^1.0.7" + define-properties: "npm:^1.2.1" + es-abstract: "npm:^1.23.3" + checksum: 10/939a5447e4a99a86f29cc97fa24f358e5071f79e34746de4c7eb2cd736ed626ad24870a1e356f33915b3b352bb87f7e4d1cebc15d1e1aaae0923777e21b1b28b + languageName: node + linkType: hard + "string.prototype.matchall@npm:^4.0.11": version: 4.0.11 resolution: "string.prototype.matchall@npm:4.0.11"