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

[Accessibility] Refactor font slider for accessibility #14817

Merged
merged 5 commits into from
Nov 15, 2017

Conversation

timroes
Copy link
Contributor

@timroes timroes commented Nov 7, 2017

This PR changes the font slider in the tag cloud editor a bit, by replacing it's non accessible popovers via two number input fields below it:

screenshot-20171107-090950

When using the slider the values in the input fields will be changed immediately, and you can use the input fields vise versa to change the font, and the slider will automatically update.

This version now is fully accessible and should work well until we build a custom range picker in our UI framework.

Fixes #12905

@timroes timroes added Feature:Tagcloud Tag cloud visualization feature Feature:Visualizations Generic visualization features (in case no more specific feature label is available) Project:Accessibility v6.1.0 v7.0.0 labels Nov 7, 2017
@timroes
Copy link
Contributor Author

timroes commented Nov 7, 2017

Jenkins, test this

@ppisljar
Copy link
Member

ppisljar commented Nov 7, 2017

in the text boxes the second value can be smaller than the first one, which isn't possible to do with slider ... should we block that ?

@timroes
Copy link
Contributor Author

timroes commented Nov 7, 2017

Changed that behavior: the absolute min/max is still enforced by the browser and the min/max attribute on the input fields, but the crossing is now improved, by manually validating that, and always limiting it to the other sliders value.

@ppisljar
Copy link
Member

ppisljar commented Nov 7, 2017

ehm ... this gives quite a weird experience ...

  • type 40 in the first box
  • try to type 60 in the second box ... you won't be able to (after typing 6 value gets automatically updated to 40 ... )

probably the check should only happen after leaving the box (or on pressing enter)

@timroes
Copy link
Contributor Author

timroes commented Nov 7, 2017

Oh shit, yeah that's true. So we basically have two options here I think about:

a) we change the ng-model-options to only apply the value to scope when bluring the input field. That way the slider wouldn't change immediately when updating the values in the text field (e.g. also by pressing up/down), but therefore we wouldn't have to bother with that above issue.
b) We rely also for the crossing on the browsers min/max behavior (what it was before the last commit), meaning you can enter any value, but it will be highlighted red if it crosses each other, and not set at all to the $scope, so when you submit the form, it will submit (and also show at that point) the last valid values it had before the invalid ones.

Any other options you see, that would be a good solution?

@ppisljar
Copy link
Member

ppisljar commented Nov 7, 2017

c) allow submitting crossing ranges, but turn them around on submit ? (so 50 - 5 turns into 5 - 50)

none of the options seem perfect ...

@cjcenizal
Copy link
Contributor

I think option A is my expected behavior. If I enter invalid input it will show up in the input fields with an error state and an error message, but the invalid input won't be reflected in the slider and won't be saved if I try to save the visualization.

@thomasneirynck
Copy link
Contributor

can we use this PR to address #11406 as well?

@timroes
Copy link
Contributor Author

timroes commented Nov 8, 2017

@thomasneirynck I would rather have a look at #14565 which is most likely the cause of that issue. I thought I checked it against 5.6 and thought it doesn't occur there. But I could check all 5.x versions for the issue again and backport #14565 appropriate.

@timroes
Copy link
Contributor Author

timroes commented Nov 10, 2017

@cjcenizal The behavior you are describing would actually be more option b not a :-) Option B would also align with other suggestions, so I basically reverted the change to use option B again, and we should consider this again when building our own ranged slider. So would welcome some reviews :-)

@thomasneirynck
Copy link
Contributor

#9168 will be a separate effort. For now, this will solve the immediate pain points of this control.

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

UX feels great! I tested with VoiceOver and it interprets the inputs clearly. I had some suggestions wrt to using UI Framework classes. Here's how it ends up looking:

image

We can expand the width of kuiTextInput--small in the UI Framework to accommodate all 3 digits cleanly, if you want.

@@ -11,6 +11,32 @@
<div class="form-group">
<label>Font Size</label>
<div class="tag-cloud-fontsize-slider"></div>
<div class="tag-cloud-fontsize-inputs">
Copy link
Contributor

Choose a reason for hiding this comment

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

You can replace this class with kuiBar.

@@ -11,6 +11,32 @@
<div class="form-group">
<label>Font Size</label>
<div class="tag-cloud-fontsize-slider"></div>
<div class="tag-cloud-fontsize-inputs">
<div class="tag-cloud-fontsize-input">
Copy link
Contributor

Choose a reason for hiding this comment

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

And then you can replace this class and the one on line 27 with kuiBarSection. Then you'll be able to delete these styles from tag_cloud.less.

type="number"
min="1"
max="{{vis.params.maxFontSize}}"
class="form-control tag-cloud-fontsize-inputfield"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can replace these classes with kuiTextInput kuiTextInput--small.

aria-label="Maximum tag font size"
aria-describedby="tagCloudFontSliderMaxUnit"
>
<span id="tagCloudFontSliderMaxUnit">px</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Screen readers read this as "P, X". Should we add aria-label="pixels" to make it clearer?

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

Looks good.

One minor suggestion, not deal breaker:

Typing in an invalid value shows a red outline. Works good, but then perhaps we should disable the play-button and show some feedback in the little error-icon next to it, similar to other places in visualize?

Another approach, but maybe we can auto-justify the input to 1 and 100, and auto-update any value that exceeds this.

@timroes
Copy link
Contributor Author

timroes commented Nov 14, 2017

@cjcenizal I updated the PR for another review. I just didn't use the kuiTextInput--small class, since we accept 100 as max value, which wouldn't fit into that, so I still wanted to have a view more pixel width on these fields. Hope that's okay with you?

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

@timroes LGTM! Re the input, we can change the kuiTextInput--small size in the UI Framework itself, so that it fits "100" as an input. I think you've exposed a flaw with that component which we can/should fix but it's not a big deal.

@timroes timroes merged commit 815cfe1 into elastic:master Nov 15, 2017
@timroes timroes deleted the fontslider-a11y branch November 15, 2017 13:36
timroes added a commit to timroes/kibana that referenced this pull request Nov 15, 2017
* Refactor font slider for accessibility, fix elastic#12905

* Limit input fields min/max values

* Prevent crossing of min/max values

* Revert "Prevent crossing of min/max values"

This reverts commit 575dfac.

* Use UI framework classes
timroes added a commit that referenced this pull request Nov 15, 2017
* Refactor font slider for accessibility, fix #12905

* Limit input fields min/max values

* Prevent crossing of min/max values

* Revert "Prevent crossing of min/max values"

This reverts commit 575dfac.

* Use UI framework classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Tagcloud Tag cloud visualization feature Feature:Visualizations Generic visualization features (in case no more specific feature label is available) Project:Accessibility release_note:enhancement v6.1.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants