Skip to content

Commit 92cd0ff

Browse files
committedAug 7, 2024
Fix formatting and add changeset
1 parent 0775948 commit 92cd0ff

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed
 

‎.changeset/witty-bulldogs-warn.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-range": minor
3+
---
4+
5+
Improving a11y of the slider by adding new label properties.

‎examples/BasicVisibleLabel.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ const BasicVisibleLabelExample: React.FC<{ rtl: boolean }> = ({ rtl }) => {
1717
flexWrap: "wrap",
1818
}}
1919
>
20-
<label
21-
onClick={ (e) => {
22-
rangeRef.current.thumbRefs[0].current.focus()
23-
}}
24-
id="unique_id"
25-
style={{
26-
flex:"auto",
27-
fontFamily:"sans-serif"
28-
}}
29-
30-
>Visible accessibility label:</label>
20+
<label
21+
onClick={(e) => {
22+
rangeRef.current.thumbRefs[0].current.focus();
23+
}}
24+
id="unique_id"
25+
style={{
26+
flex: "auto",
27+
fontFamily: "sans-serif",
28+
}}
29+
>
30+
Visible accessibility label:
31+
</label>
3132

3233
<Range
3334
labelledBy="unique_id"
@@ -40,7 +41,6 @@ const BasicVisibleLabelExample: React.FC<{ rtl: boolean }> = ({ rtl }) => {
4041
onChange={(values) => setValues(values)}
4142
renderTrack={({ props, children }) => (
4243
<div
43-
4444
onMouseDown={props.onMouseDown}
4545
onTouchStart={props.onTouchStart}
4646
style={{

‎src/Range.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ class Range extends React.Component<IProps> {
704704
"aria-valuenow": value,
705705
draggable: false,
706706
ref: this.thumbRefs[index],
707-
"aria-label" : label,
708-
"aria-labelledby" : labelledBy,
707+
"aria-label": label,
708+
"aria-labelledby": labelledBy,
709709
role: "slider",
710710
onKeyDown: disabled ? voidFn : this.onKeyDown,
711711
onKeyUp: disabled ? voidFn : this.onKeyUp,

‎src/range.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const AnimatingContainer: React.FC<{ rtl: boolean }> = ({ rtl }) => (
3434
export const Basic: React.FC<{ rtl: boolean }> = ({ rtl }) => (
3535
<BasicExample rtl={rtl} />
3636
);
37-
export const BasicVisibleLabel : React.FC<{ rtl: boolean }> = ({ rtl }) => (
37+
export const BasicVisibleLabel: React.FC<{ rtl: boolean }> = ({ rtl }) => (
3838
<BasicVisibleLabelExample rtl={rtl} />
3939
);
4040
export const BasicWithBorder: React.FC<{ rtl: boolean }> = ({ rtl }) => (

‎src/types.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export interface ITrackBackground {
99
rtl?: boolean;
1010
}
1111
export interface IProps {
12-
label: string,
13-
labelledBy: string,
12+
label: string;
13+
labelledBy: string;
1414
values: number[];
1515
min: number;
1616
max: number;
@@ -50,8 +50,8 @@ export interface IThumbProps {
5050
key: number;
5151
style: React.CSSProperties;
5252
tabIndex?: number;
53-
"aria-label": string,
54-
"aria-labelledby": string,
53+
"aria-label": string;
54+
"aria-labelledby": string;
5555
"aria-valuemax": number;
5656
"aria-valuemin": number;
5757
"aria-valuenow": number;

0 commit comments

Comments
 (0)
Please sign in to comment.