Skip to content

Commit 27fcd7c

Browse files
authored
fix: Improve accessibility and code quality (#1985)
* fix: Replace deprecated onKeyPress with onKeyDown This commit updates the component to use the recommended onKeyDown event handler, resolving a deprecation warning in React. * style: Fix lint error for non-null assertion Replaced the non-null assertion with a type assertion 'as HTMLElement' to resolve a linting error. This change ensures better type safety and code quality. * fix: Improve color contrast ratio This commit adjusts the background and foreground colors to meet WCAG AA standards. This fix ensures that text is readable and accessible for all users, including those with low vision. * style: Remove empty css ruleset Removed the empty class declaration. This is a code style cleanup that doesn't change functionality but improves the maintainability and readability of the codebase. * docs: Add meta description to document and language attribute to root element * fix: Associate labels with form elements This commit ensures all form input elements are correctly associated with their labels using the 'for' attribute. This is a critical fix for users of assistive technologies and provides a better user experience for everyone. * style: Use single quotes for HTML attributes
1 parent 4650cb0 commit 27fcd7c

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

examples/react/public/App.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@
2525
margin-bottom: 10px;
2626
}
2727

28-
.react-player {}
29-
3028
.faded {
31-
color: rgba(0, 0, 0, .5);
29+
color: rgba(0, 0, 0,.6);
3230
}
3331

3432
.footer {

examples/react/public/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<!doctype html>
2-
<html>
2+
<html lang='en'>
33
<head>
44
<meta charset='utf-8'>
55
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
66
<title>ReactPlayer Demo</title>
7+
<meta name='description' content='A React component for playing a variety of URLs, including file paths, Mux, YouTube, Vimeo, and Wistia'>
78
<link rel='stylesheet' href='./reset.css'>
89
<link rel='stylesheet' href='./defaults.css'>
910
<link rel='stylesheet' href='./range.css'>

examples/react/src/App.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,10 @@ const App = () => {
309309
</td>
310310
</tr>
311311
<tr>
312-
<th>Seek</th>
312+
<th><label htmlFor="seek">Seek</label></th>
313313
<td>
314314
<input
315+
id="seek"
315316
type="range"
316317
min={0}
317318
max={0.999999}
@@ -324,9 +325,10 @@ const App = () => {
324325
</td>
325326
</tr>
326327
<tr>
327-
<th>Volume</th>
328+
<th><label htmlFor="volume">Volume</label></th>
328329
<td>
329330
<input
331+
id="volume"
330332
type="range"
331333
min={0}
332334
max={1}

examples/react/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import { createRoot } from 'react-dom/client';
33
import App from './App';
44

55
const container = document.getElementById('app');
6-
const root = createRoot(container!);
6+
const root = createRoot(container as HTMLElement);
77
root.render(<App />);

src/Preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const Preview = ({
112112
className="react-player__preview"
113113
tabIndex={previewTabIndex}
114114
onClick={handleClick}
115-
onKeyPress={handleKeyPress}
115+
onKeyDown={handleKeyPress}
116116
{...(previewAriaLabel ? { 'aria-label': previewAriaLabel } : {})}
117117
>
118118
{isElement ? light : null}

0 commit comments

Comments
 (0)