Skip to content
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

Merged
merged 26 commits into from
Nov 22, 2016
Merged

aria-valuetext as formatter value #646

merged 26 commits into from
Nov 22, 2016

Conversation

mediaformat
Copy link
Contributor

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

@@ -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]));
Copy link
Collaborator

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!

Copy link
Contributor Author

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
@mediaformat
Copy link
Contributor Author

I've added a test, and added a check that the value isNaN to use aria-valuetext, as per the spec

@rovolution
Copy link
Collaborator

@mediaformat tests look good! however, looks like it is failing the lint check on CI:

image

@mediaformat
Copy link
Contributor Author

Ok, it looks like I need to do this DOM less...

@seiyria
Copy link
Owner

seiyria commented Nov 9, 2016

No. Just declare the variables with var instead of making them global (if
I'm reading this right).

On Wed, Nov 9, 2016, 10:07 Django Doucet notifications@github.com wrote:

Ok, it looks like I need to do this DOM less...


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#646 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAum2SfHqZf5OoVSKlmKRnANJuieE3kVks5q8e_UgaJpZM4KlwK0
.

@@ -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]));
Copy link
Collaborator

@rovolution rovolution Nov 10, 2016

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?

Copy link
Collaborator

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?

Copy link
Contributor Author

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/

Copy link
Contributor Author

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

Copy link
Collaborator

@rovolution rovolution Nov 10, 2016

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/

Copy link
Collaborator

@rovolution rovolution Nov 10, 2016

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

Copy link
Collaborator

@rovolution rovolution Nov 12, 2016

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() {
Copy link
Collaborator

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]));
Copy link
Collaborator

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?

@mediaformat
Copy link
Contributor Author

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. |
Copy link
Collaborator

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]));
Copy link
Collaborator

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!

Copy link
Collaborator

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

Copy link
Contributor Author

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...

Copy link
Contributor Author

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

Copy link
Collaborator

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
@mediaformat
Copy link
Contributor Author

Yeah it's a bit hard to see where things went wrong when the error message (for testSliderC) says:

Expected [ 'Tuesday', 'Thursday' ] to be [ 'Tuesday', 'Thursday' ]

@rovolution
Copy link
Collaborator

rovolution commented Nov 19, 2016

@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]);

};

//Formatter is used for ranges
var testSliderC = $("#accessibilitySliderC").slider({
Copy link
Collaborator

@rovolution rovolution Nov 21, 2016

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was it!

@rovolution
Copy link
Collaborator

just pulled your branch down locally to verify everything...it looks great! merging now

@rovolution rovolution merged commit 07210e0 into seiyria:master Nov 22, 2016
@seiyria
Copy link
Owner

seiyria commented Nov 22, 2016

very nice PR!

@mediaformat
Copy link
Contributor Author

Thank you sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants