-
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
Conversation
@@ -1148,6 +1148,7 @@ const windowIsDefined = (typeof window === "object"); | |||
|
|||
this.handle1.style[this.stylePos] = positionPercentages[0]+'%'; | |||
this.handle1.setAttribute('aria-valuenow', 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a unit test that checks if the aria-valuetext
is updated appropriately when the slider value is changed? Thanks!
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.
will do!
Added a check that formatter is used
-Sets the aria-valuetext to 'formatter' value -Does not use aria-valuetext if 'formatter' is not used
I've added a test, and added a check that the value isNaN to use aria-valuetext, as per the spec |
@mediaformat tests look good! however, looks like it is failing the lint check on CI: |
Ok, it looks like I need to do this DOM less... |
No. Just declare the variables with var instead of making them global (if On Wed, Nov 9, 2016, 10:07 Django Doucet notifications@github.com wrote:
|
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
can we set this for handle2
as well?
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 also add a section to our README.md
that documents this new ARIA property and add an example to our /tpl/index.tpl
page?
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.
about handle2
...
What is it's purpose?
It always seems to be hidden and its aria-valuenow is unchanged...and defaults to 1 even when set to something else : https://fiddle.jshell.net/bbw6z63n/7/
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.
which would be confusing to screen readers
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.
about handle2...
What is it's purpose?
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
@mediaformat we are also setting aria-valuenow
on this.handle2
below (line 1155), so I think it would be valuable to set it on handle2 as well
@@ -0,0 +1,27 @@ | |||
it("Sets the aria-valuetext to 'formatter' value", function() { |
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.
can you wrap this entire spec in a describe
block?
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
could you also add a section to our README.md
that documents this new ARIA property and add an example to our /tpl/index.tpl
page?
Weird, it fails with Describe, and Passes without it!? |
@@ -187,7 +187,7 @@ Options can be passed either as a data (data-slider-foo) attribute, or as part o | |||
| handle | string | 'round' | handle shape. Accepts: 'round', 'square', 'triangle' or 'custom' | | |||
| reversed | bool | false | whether or not the slider should be reversed | | |||
| enabled | bool | true | whether or not the slider is initially enabled | | |||
| formatter | function | returns the plain value | formatter callback. Return the value wanted to be displayed in the tooltip | | |||
| formatter | function | returns the plain value | formatter callback. Return the value wanted to be displayed in the tooltip, useful for string values. If a string is returned it will be indicated in an aria-valuetext attribute. | |
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
|
||
this.handle2.style[this.stylePos] = positionPercentages[1]+'%'; | ||
this.handle2.setAttribute('aria-valuenow', this._state.value[1]); | ||
if (isNaN(this.options.formatter(this._state.value[1])) ) { | ||
this.handle2.setAttribute('aria-valuetext', this.options.formatter(this._state.value[1])); |
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.
great! if you add a test for this in your unit test suite, i think this is good to go!
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.
@mediaformat have you had a chance to check this out? I would love to merge this in once the test for a multi-handle slider is complete
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.
The multi-handle works in practice : https://fiddle.jshell.net/bbw6z63n/11/
But I can't seem to get the test to work, I've committed it, maybe you'll be able to see why it doesn't work...
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.
maybe it's not failing, lol
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.
i wonder why this test is still failing (yet passes when the describe
is not there)
Test is failing, not sure why
Does not use aria-valuetext if 'formatter' is not used. Code was targeting testSliderA testSliderC still failing mysteriously
Yeah it's a bit hard to see where things went wrong when the error message (for testSliderC) says:
|
@mediaformat instead of that, could you re-write this to be the following? expect(bothMessages[0]).toBe(expectedMessageC[0]);
expect(bothMessages[1]).toBe(expectedMessageC[1]); |
works locally on jasmine standalone 2.5.2
works locally
}; | ||
|
||
//Formatter is used for ranges | ||
var testSliderC = $("#accessibilitySliderC").slider({ |
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.
oh i think i know why this is failing @mediaformat!
I believe you forget to add an input element with id #accessibilitySliderC"
to the /tpl/SpecRunner.tpl file.
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.
that was it!
just pulled your branch down locally to verify everything...it looks great! merging now |
very nice PR! |
Thank you sir! |
Pull Requests
Original issue : Feature Request : aria-valuetext as formatter value
#641
Example of feature in action:
https://fiddle.jshell.net/bbw6z63n/4/
Issue #641