-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
aria-valuetext as formatter value #646
Changes from 9 commits
868358e
26982e1
3831d4a
a589672
0495b7c
3741bd4
8c92c31
9260f09
c84c69d
023cec9
cd099c4
d8bfadd
352e495
454c745
1a1867c
a7b1f3c
6609ccc
2c13f59
f6e356d
01d3504
ae6b81a
00f14c5
72a9fd6
a5d1323
071d929
1cbcdf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1148,6 +1148,9 @@ const windowIsDefined = (typeof window === "object"); | |
|
||
this.handle1.style[this.stylePos] = positionPercentages[0]+'%'; | ||
this.handle1.setAttribute('aria-valuenow', this._state.value[0]); | ||
if (isNaN(this.options.formatter(this._state.value[0])) ) { | ||
this.handle1.setAttribute('aria-valuetext', this.options.formatter(this._state.value[0])); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we set this for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you also add a section to our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. which would be confusing to screen readers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Purpose is the use case where we have a 2 handle slider - see Example 2 in our examples page: http://seiyria.com/bootstrap-slider/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And the README update is so that users of this library know which ARIA attributes are set on the slider There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mediaformat we are also setting |
||
} | ||
|
||
this.handle2.style[this.stylePos] = positionPercentages[1]+'%'; | ||
this.handle2.setAttribute('aria-valuenow', this._state.value[1]); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
it("Sets the aria-valuetext to 'formatter' value", function() { | ||
var textValArray = new Array('Monday','Wednesday','Friday'); | ||
var tooltipFormatter = function(value) { | ||
var arrActiveValue = value; | ||
return 'Current value: ' + textValArray[arrActiveValue-1]; | ||
}; | ||
|
||
//Formatter is used | ||
var testSlider = $("#accessibilitySliderA").slider({ | ||
formatter : tooltipFormatter | ||
}); | ||
testSlider.slider('setValue', 2); | ||
|
||
var tooltipMessage = $("#accessibilitySliderA").siblings(".slider").children(".min-slider-handle").attr("aria-valuetext"); | ||
var expectedMessage = tooltipFormatter(2); | ||
expect(tooltipMessage).toBe(expectedMessage); | ||
|
||
}); | ||
it("Does not use aria-valuetext if 'formatter' is not used", function() { | ||
|
||
//Formatter is not used | ||
var testSliderB = $("#accessibilitySliderB").slider({}); | ||
testSliderB.slider('setValue', 2); | ||
|
||
var ariaValueText = $("#accessibilitySliderB").siblings(".slider").children(".min-slider-handle").attr("aria-valuetext"); | ||
expect(ariaValueText).not.toBeDefined(); | ||
}); | ||
|
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.
could you wrap the "aria-valuetext" string in backticks (`) so that it stands out visually in the README?
aria-valuetext