Skip to content

Commit

Permalink
Fix formatting and add changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
tajo committed Aug 7, 2024
1 parent 0775948 commit 92cd0ff
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-bulldogs-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-range": minor
---

Improving a11y of the slider by adding new label properties.
24 changes: 12 additions & 12 deletions examples/BasicVisibleLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ const BasicVisibleLabelExample: React.FC<{ rtl: boolean }> = ({ rtl }) => {
flexWrap: "wrap",
}}
>
<label
onClick={ (e) => {
rangeRef.current.thumbRefs[0].current.focus()
}}
id="unique_id"
style={{
flex:"auto",
fontFamily:"sans-serif"
}}

>Visible accessibility label:</label>
<label
onClick={(e) => {
rangeRef.current.thumbRefs[0].current.focus();
}}
id="unique_id"
style={{
flex: "auto",
fontFamily: "sans-serif",
}}
>
Visible accessibility label:
</label>

<Range
labelledBy="unique_id"
Expand All @@ -40,7 +41,6 @@ const BasicVisibleLabelExample: React.FC<{ rtl: boolean }> = ({ rtl }) => {
onChange={(values) => setValues(values)}
renderTrack={({ props, children }) => (
<div

onMouseDown={props.onMouseDown}
onTouchStart={props.onTouchStart}
style={{
Expand Down
4 changes: 2 additions & 2 deletions src/Range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,8 @@ class Range extends React.Component<IProps> {
"aria-valuenow": value,
draggable: false,
ref: this.thumbRefs[index],
"aria-label" : label,
"aria-labelledby" : labelledBy,
"aria-label": label,
"aria-labelledby": labelledBy,
role: "slider",
onKeyDown: disabled ? voidFn : this.onKeyDown,
onKeyUp: disabled ? voidFn : this.onKeyUp,
Expand Down
2 changes: 1 addition & 1 deletion src/range.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const AnimatingContainer: React.FC<{ rtl: boolean }> = ({ rtl }) => (
export const Basic: React.FC<{ rtl: boolean }> = ({ rtl }) => (
<BasicExample rtl={rtl} />
);
export const BasicVisibleLabel : React.FC<{ rtl: boolean }> = ({ rtl }) => (
export const BasicVisibleLabel: React.FC<{ rtl: boolean }> = ({ rtl }) => (
<BasicVisibleLabelExample rtl={rtl} />
);
export const BasicWithBorder: React.FC<{ rtl: boolean }> = ({ rtl }) => (
Expand Down
8 changes: 4 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export interface ITrackBackground {
rtl?: boolean;
}
export interface IProps {
label: string,
labelledBy: string,
label: string;
labelledBy: string;
values: number[];
min: number;
max: number;
Expand Down Expand Up @@ -50,8 +50,8 @@ export interface IThumbProps {
key: number;
style: React.CSSProperties;
tabIndex?: number;
"aria-label": string,
"aria-labelledby": string,
"aria-label": string;
"aria-labelledby": string;
"aria-valuemax": number;
"aria-valuemin": number;
"aria-valuenow": number;
Expand Down

0 comments on commit 92cd0ff

Please sign in to comment.