Skip to content

Add keyboard controls for drag and drop problems.#1394

Merged
somiaj merged 2 commits into
openwebwork:PG-2.21from
drgrice1:accessible-drag-and-drop
May 19, 2026
Merged

Add keyboard controls for drag and drop problems.#1394
somiaj merged 2 commits into
openwebwork:PG-2.21from
drgrice1:accessible-drag-and-drop

Conversation

@drgrice1
Copy link
Copy Markdown
Member

@drgrice1 drgrice1 commented Apr 8, 2026

This is for problmes that use the dragndrop.js JavaScript and the DragNDrop.pm module via the draggableProof.pl and draggableSubsets.pl macros.

The elements in a drag and drop list can now be focused using tab and shift-tab. Once focused the arrow keys move the elements around. If an element is moved with the keyboard controls the changes are announced in a visually hidden span. Note that drag and drop actions via the mouse cursor are not aria announced for now. I am assuming that a screen reader user would not be using the mouse for drag and drop.

There is now also a "Drag and Drop Help" button that is shown below the drag and drop lists. If pressed, help is shown describing the keyboard controls. This help can be customized by the problem.

There are new options for the macros that allow for customizing the help and associated texts. See the updated POD in the module and macros for details. Also, I don't like that there are some options that are for the DragNDrop.pm package that are passed in from the macros, but are different in the macros than in the module. Basically the first letter is upper case in the macros, but lower case in the module. So the upper case first letter variants is deprecated (but will still work with a compatibility layer). I don't like that the macros use Pascal case to begin with for options. Options should be camel case.

Note that I also made all of the texts for the drag and drop object translatable via maketext. The texts can be customized per problem as mentioned above, but if only a translation is needed there is no need for such customization.

@drgrice1 drgrice1 force-pushed the accessible-drag-and-drop branch 2 times, most recently from a17a7d1 to 1bef862 Compare April 21, 2026 21:39
@drgrice1 drgrice1 force-pushed the accessible-drag-and-drop branch from 1bef862 to 392a0fa Compare April 28, 2026 21:43
@drgrice1 drgrice1 force-pushed the accessible-drag-and-drop branch from 392a0fa to f8e605d Compare May 18, 2026 11:14
Copy link
Copy Markdown
Member

@pstaabp pstaabp left a comment

Choose a reason for hiding this comment

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

Was a little tricky to get started, but the help was helpful and I got a handle on this. Great improvement.

Comment thread lib/DragNDrop.pm Outdated

Label shown for the universal set bucket if C<showUniversalSet> is 1.

=item addFromUnversalText
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like a typo.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am not sure where you see a typo here? addFromUniversalText is correct.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's missing an "i" in "Universal".

drgrice1 added 2 commits May 19, 2026 16:27
This is for problmes that use the `dragndrop.js` JavaScript and the
`DragNDrop.pm` module via the `draggableProof.pl` and
`draggableSubsets.pl` macros.

The elements in a drag and drop list can now be focused using tab and
shift-tab.  Once focused the arrow keys move the elements around.  If an
element is moved with the keyboard controls the changes are announced in
a visually hidden span.  Note that drag and drop actions via the mouse
cursor are not aria announced for now.  I am assuming that a screen
reader user would not be using the mouse for drag and drop.

There is now also a "Drag and Drop Help" button that is shown below the
drag and drop lists.  If pressed, help is shown describing the keyboard
controls.  This help can be customized by the problem.

There are new options for the macros that allow for customizing the help
and associated texts.  See the updated POD in the module and macros for
details.  Also, I don't like that there are some options that are for
the `DragNDrop.pm` package that are passed in from the macros, but are
different in the macros than in the module.  Basically the first letter
is upper case in the macros, but lower case in the module.  So the upper
case first letter variants is deprecated (but will still work with a
compatibility layer).  I don't like that the macros use Pascal case to
begin with for options.  Options should be camel case.

Note that I also made all of the texts for the drag and drop object
translatable via `maketext`.  The texts can be customized per problem as
mentioned above, but if only a translation is needed there is no need
for such customization.
@drgrice1 drgrice1 force-pushed the accessible-drag-and-drop branch from ca2e4ba to c792116 Compare May 19, 2026 21:27
Copy link
Copy Markdown
Contributor

@somiaj somiaj left a comment

Choose a reason for hiding this comment

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

Tested my problems work just fine with the keyboard. Nice improvement.

@somiaj somiaj merged commit 7c26098 into openwebwork:PG-2.21 May 19, 2026
3 checks passed
@drgrice1 drgrice1 deleted the accessible-drag-and-drop branch May 19, 2026 23:00
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.

4 participants