Commit Graph

20 Commits

Author SHA1 Message Date
Tom Byers
551f7b91f4 Test and then fix focus when module state changes
Includes tests for this.
2019-08-07 10:23:09 +01:00
Tom Byers
c11c054323 Fix option selection for keyboard users
Keyboard users select a time slot by moving to the
radio for that slot, using the arrow keys, and
selecting it by pressing 'space' or 'enter', like
a `<select>`.

We allow this by listening for 'keydown' events
from the 'enter' or 'space' keys on time slot
radios that are checked.

Browsers fire 'click' events alongside the
'keydown' event meaning it's possible for the
code that makes the selection to be run twice.

We currently guard against this by checking for
the `pageX` property of the event object,
reasoning that a click event fired by a key press
won't have a cursor position.

Most browsers we support set it to `0` but it
isn't always the case:

https://dom-event-test.glitch.me/results.html

For those browsers, the `!event.pageX` condition
resolves correctly so this works. Safari and
versions of Internet Explorer before 11 however,
set it to a positive number.

In those browsers, moving the selection between
radios using the arrow keys fired a 'click' event
which, in Safari and IE<11, was treated as a
mouse/touch event and so confirmed the selection.
This made it impossible to select a later time.

These changes replace the 'click' event on time
slots with an artifical one that tracks
mouse/trackpad clicks by listening for a
'mousedown' followed by a 'mouseup' on a time
slot. This doesn't fire on key presses so avoids
the problem.
2019-08-07 10:23:09 +01:00
Tom Byers
5186402958 Add tests for different selection methods
Adds tests for selection by keyboard, involving
making a selection with the arrow keys and
confirming it with the space or enter keys.
2019-08-07 10:23:09 +01:00
Tom Byers
6854361375 Expand event helpers
Extends triggerEvent, allowing the creation of
different types of event, and to change the data
on its object. Also fakes the positional data
browsers add to the event object.

Also adds helpers for simulating:
- all the events for a mouse click
- the events invovled in moving the selection in a radio group
2019-08-07 10:23:09 +01:00
Tom Byers
25b2414cec Add tests for radioSelect module 2019-08-07 10:23:09 +01:00
Tom Byers
1a5d40312a Move window mock functions into helper class 2019-06-12 16:03:35 +01:00
Tom Byers
1082a37750 Update call out to sticky JS, with test for it 2019-06-12 16:03:26 +01:00
Tom Byers
0131f0c1b1 Move setup/teardown out of tests 2019-06-12 16:03:18 +01:00
Tom Byers
435334ba9c Add tests for full-screen table module 2019-06-12 16:03:09 +01:00
Tom Byers
b9a2cc1ec5 Add tests for listEntry.js 2019-05-16 15:36:47 +01:00
Tom Byers
ccd09b9fd7 Revert "Merge pull request #2969 from alphagov/revert-2956-progressively-enhance-folder-permissions"
This reverts commit 8266f3d65c, reversing
changes made to b2a38fe222.
2019-05-15 14:26:51 +01:00
Tom Byers
0e6caa7fda Revert "Progressively enhance folder permissions" 2019-05-13 16:19:24 +01:00
Tom Byers
d75c26eb83 Make done button, and its surround, sticky 2019-05-10 14:21:58 +01:00
Tom Byers
7328649537 Combine 'Change' and 'Done' buttons into one
Includes addition of classes by JS to ensure CSS
selectors don't have to reference the data
attributes.
2019-05-10 14:16:03 +01:00
Chris Hill-Scott
923ac7190c Add a hint when no team members are selected
This helps clarify that you will still be able to see the folder.
Follows the phrasing used for the "No folders…" message.
2019-05-09 13:43:04 +01:00
Tom Byers
1ffa8c8915 Only show the folder icon if fields are folders 2019-05-09 11:25:28 +01:00
Tom Byers
42a9a0cf23 Make selection summary a live region
Live regions need to be in the original HTML of
the page to work. We were generating the summary
in JS.

This changes the JS to only generate the contents
of the summary so changes to its contents are
announces by the existing live-region.
2019-05-08 17:16:06 +01:00
Tom Byers
089ebf2c7a Add tests for collapsible checkboxes 2019-05-08 17:08:20 +01:00
Tom Byers
90ad8b4ed0 Add helpers for JS tests
To help with asserting some things which were
repeated in the tests.
2019-05-08 17:08:20 +01:00
Tom Byers
00c1ebf02a Add test for autofocus.js
One of the simplest of our JavaScript files to
test how difficult this is.

Answer is not too bad and includes the file
needing a DOM to operate on and jQuery in the
global scope.
2019-04-24 10:46:55 +01:00