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

Fix aria expanded and height of option select #1146

Merged
merged 3 commits into from
Sep 20, 2017

Conversation

andysellick
Copy link
Contributor

@andysellick andysellick commented Sep 18, 2017

  • set aria-expanded to true by default when initialising rather than performing a check as it will always be open on load, unless it's set to be closed in which case the code will change it back to false anyway as it then closes it
  • fix for height issue by calling setheight on initialisation, code is structured already so that it won't get called again unless it needs to be
  • fixes Option selects aren’t set up correctly when open on page load #860
  • includes some CSS optimisation/improvements (tested in various including IE8, 9, 10, 11, Firefox current, 48, Edge, Chrome current, 54, Opera 40, Safari 5.1, iphone 6s, ipad mini)

Before:

screen shot 2017-09-18 at 10 49 26

After:

screen shot 2017-09-19 at 12 50 59

https://govuk-static-pr-1146.herokuapp.com/component-guide/option_select

@fofr fofr temporarily deployed to govuk-static-pr-1146 September 18, 2017 09:50 Inactive
@andysellick andysellick changed the title Fix aria expanded and height of option select [DO NOT MERGE] Fix aria expanded and height of option select Sep 18, 2017
@NickColley
Copy link
Contributor

Could we create a failing test for this?

@andysellick
Copy link
Contributor Author

On it.

@fofr fofr temporarily deployed to govuk-static-pr-1146 September 18, 2017 10:05 Inactive
@andysellick andysellick changed the title [DO NOT MERGE] Fix aria expanded and height of option select Fix aria expanded and height of option select Sep 18, 2017
@@ -86,6 +86,10 @@ describe('GOVUK.OptionSelect', function() {
expect(optionSelect.isClosed()).toBe(false);
});

it ('has called setupHeight as part of initialisation', function(){
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make the test name to what we're testing, which is that it's expanded by default, and update the test to reflect this?

@andysellick andysellick changed the title Fix aria expanded and height of option select [DO NOT MERGE] Fix aria expanded and height of option select Sep 18, 2017
@andysellick andysellick force-pushed the fix-options-select-aria-and-height branch from cb82833 to 95edbcd Compare September 18, 2017 10:43
@fofr fofr temporarily deployed to govuk-static-pr-1146 September 18, 2017 10:43 Inactive
@andysellick andysellick changed the title [DO NOT MERGE] Fix aria expanded and height of option select Fix aria expanded and height of option select Sep 18, 2017
@fofr
Copy link
Contributor

fofr commented Sep 18, 2017

@andysellick It's helpful to include links for review like:
https://govuk-static-pr-1146.herokuapp.com/component-guide/option_select

@@ -86,6 +86,17 @@ describe('GOVUK.OptionSelect', function() {
expect(optionSelect.isClosed()).toBe(false);
});

it ('sets the height of the options container as part of initialisation', function(){
Copy link
Contributor

@NickColley NickColley Sep 18, 2017

Choose a reason for hiding this comment

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

These tests could communicate the bug we're fixing, if we named this test around how we're checking the component is expanded correctly we'd notice that we're testing the height is set but we're not testing that the aria-expanded attribute is set properly.

Copy link
Contributor

Choose a reason for hiding this comment

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

We need a separate second test to check that aria-expanded has the correct value(s)

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 first two tests in the file now cover this for both open and closed initial states.

@@ -124,12 +135,6 @@ describe('GOVUK.OptionSelect', function() {
expect($optionSelectHTML.hasClass('js-closed')).toBe(false);
});

it ('calls setupHeight()', function(){
Copy link
Contributor

Choose a reason for hiding this comment

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

Why delete this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test assumes setupHeight gets called when the option select is opened, but that's now not always the case. setupHeight is called on init if the option select is in the expanded state, but not if it's collapsed. I'm writing other tests to fill this gap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have now put this test back in a modified form.

@fofr
Copy link
Contributor

fofr commented Sep 18, 2017

Visual regression picked up on the changes:
http://govuk-static-pr-1146.surge.sh/gallery.html

@andysellick andysellick force-pushed the fix-options-select-aria-and-height branch from 95edbcd to 85b9039 Compare September 18, 2017 15:51
@fofr fofr temporarily deployed to govuk-static-pr-1146 September 18, 2017 15:51 Inactive
@andysellick andysellick force-pushed the fix-options-select-aria-and-height branch from 85b9039 to 5896df6 Compare September 19, 2017 08:51
@fofr fofr temporarily deployed to govuk-static-pr-1146 September 19, 2017 08:51 Inactive
@NickColley
Copy link
Contributor

@andysellick can you put in the PR which browsers/devices you've tested the CSS changes against?

@andysellick andysellick force-pushed the fix-options-select-aria-and-height branch from 5896df6 to 27cb21c Compare September 19, 2017 12:56
@fofr fofr temporarily deployed to govuk-static-pr-1146 September 19, 2017 12:56 Inactive
- set aria-expanded to true by default when initialising rather than performing a check as it will always be open on load, unless it's set to be closed in which case the code will change it back to false anyway as it closes it
- fix for height issue by calling setheight on initialisation, code is structured already so that it won't get called again unless it needs to be
- fixes #860
- remove test to check setupheight is called on open, as now called on init
- add test to check that a height is set during init
- use display block on labels rather than inline block and having to set widths
- add a bit of padding right to labels to smarten them up a bit
- change overflow-y from scroll to auto on label container so scrollbar isn't always present
@andysellick andysellick merged commit 4dbd84d into master Sep 20, 2017
@andysellick andysellick deleted the fix-options-select-aria-and-height branch September 20, 2017 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option selects aren’t set up correctly when open on page load
3 participants