Add keyboard controls for drag and drop problems.#1394
Merged
Conversation
a17a7d1 to
1bef862
Compare
1bef862 to
392a0fa
Compare
392a0fa to
f8e605d
Compare
pstaabp
approved these changes
May 19, 2026
pstaabp
left a comment
Member
There was a problem hiding this comment.
Was a little tricky to get started, but the help was helpful and I got a handle on this. Great improvement.
pstaabp
reviewed
May 19, 2026
|
|
||
| Label shown for the universal set bucket if C<showUniversalSet> is 1. | ||
|
|
||
| =item addFromUnversalText |
Member
Author
There was a problem hiding this comment.
I am not sure where you see a typo here? addFromUniversalText is correct.
Contributor
There was a problem hiding this comment.
It's missing an "i" in "Universal".
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.
ca2e4ba to
c792116
Compare
somiaj
approved these changes
May 19, 2026
somiaj
left a comment
Contributor
There was a problem hiding this comment.
Tested my problems work just fine with the keyboard. Nice improvement.
drgrice1
added a commit
to drgrice1/pg
that referenced
this pull request
Jun 6, 2026
I accidentally removed the default value for the `indices` argument to the `htmlBucket` function in openwebwork#1394. That breaks the "Add Bucket" button because when it constructs a new `Bucket` there are no `indices`. This happened because I converted this JavaScript into TypeScript in a webpack built project for testing, and in the conversion back to JavaScript I deleted the typing that was added to the parameter, but was to aggressive in the deletion, and also deleted the default value. For a basic problem to test with you can use: ```Perl DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'MathObjects.pl', 'draggableSubsets.pl'); $draggable = DraggableSubsets( [ '\(e\)', '\(r\)', '\(r^2\)', '\(s\)', '\(sr\)', '\(sr^2\)' ], [ [ 0, 3 ], [ 1, 4 ], [ 2, 5 ] ], DefaultSubsets => [ { label => 'Coset 1', indices => [ 0 .. 3 ], removable => 0 }, { label => 'Coset 2', indices => [4], removable => 1 }, { label => 'Coset 3', indices => [5], removable => 1 } ], BucketLabelFormat => 'Coset %s', AddButtonText => 'Add Coset', RemoveButtonText => 'Remove Coset', ); BEGIN_PGML Let [``G = D_3 = \{ e,r,r^2, s,sr,sr^2 \}``] be the Dihedral group of order [`6`], where [`r`] is the counter-clockwise rotation by [`2\pi/3`], and [`s`] is the reflection across the [`x`]-axis. Partition [`G = D_3`] into *right* cosets of the subgroup [`H = \{ e, s \}`]. Give your result by dragging the following elements into separate buckets, each corresponding to a coset. [_]{$draggable} END_PGML ENDDOCUMENT(); ```
drgrice1
added a commit
that referenced
this pull request
Jun 7, 2026
I accidentally removed the default value for the `indices` argument to the `htmlBucket` function in #1394. That breaks the "Add Bucket" button because when it constructs a new `Bucket` there are no `indices`. This happened because I converted this JavaScript into TypeScript in a webpack built project for testing, and in the conversion back to JavaScript I deleted the typing that was added to the parameter, but was to aggressive in the deletion, and also deleted the default value. For a basic problem to test with you can use: ```Perl DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'MathObjects.pl', 'draggableSubsets.pl'); $draggable = DraggableSubsets( [ '\(e\)', '\(r\)', '\(r^2\)', '\(s\)', '\(sr\)', '\(sr^2\)' ], [ [ 0, 3 ], [ 1, 4 ], [ 2, 5 ] ], DefaultSubsets => [ { label => 'Coset 1', indices => [ 0 .. 3 ], removable => 0 }, { label => 'Coset 2', indices => [4], removable => 1 }, { label => 'Coset 3', indices => [5], removable => 1 } ], BucketLabelFormat => 'Coset %s', AddButtonText => 'Add Coset', RemoveButtonText => 'Remove Coset', ); BEGIN_PGML Let [``G = D_3 = \{ e,r,r^2, s,sr,sr^2 \}``] be the Dihedral group of order [`6`], where [`r`] is the counter-clockwise rotation by [`2\pi/3`], and [`s`] is the reflection across the [`x`]-axis. Partition [`G = D_3`] into *right* cosets of the subgroup [`H = \{ e, s \}`]. Give your result by dragging the following elements into separate buckets, each corresponding to a coset. [_]{$draggable} END_PGML ENDDOCUMENT(); ```
pstaabp
pushed a commit
to pstaabp/pg
that referenced
this pull request
Jul 6, 2026
I accidentally removed the default value for the `indices` argument to the `htmlBucket` function in openwebwork#1394. That breaks the "Add Bucket" button because when it constructs a new `Bucket` there are no `indices`. This happened because I converted this JavaScript into TypeScript in a webpack built project for testing, and in the conversion back to JavaScript I deleted the typing that was added to the parameter, but was to aggressive in the deletion, and also deleted the default value. For a basic problem to test with you can use: ```Perl DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'MathObjects.pl', 'draggableSubsets.pl'); $draggable = DraggableSubsets( [ '\(e\)', '\(r\)', '\(r^2\)', '\(s\)', '\(sr\)', '\(sr^2\)' ], [ [ 0, 3 ], [ 1, 4 ], [ 2, 5 ] ], DefaultSubsets => [ { label => 'Coset 1', indices => [ 0 .. 3 ], removable => 0 }, { label => 'Coset 2', indices => [4], removable => 1 }, { label => 'Coset 3', indices => [5], removable => 1 } ], BucketLabelFormat => 'Coset %s', AddButtonText => 'Add Coset', RemoveButtonText => 'Remove Coset', ); BEGIN_PGML Let [``G = D_3 = \{ e,r,r^2, s,sr,sr^2 \}``] be the Dihedral group of order [`6`], where [`r`] is the counter-clockwise rotation by [`2\pi/3`], and [`s`] is the reflection across the [`x`]-axis. Partition [`G = D_3`] into *right* cosets of the subgroup [`H = \{ e, s \}`]. Give your result by dragging the following elements into separate buckets, each corresponding to a coset. [_]{$draggable} END_PGML ENDDOCUMENT(); ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is for problmes that use the
dragndrop.jsJavaScript and theDragNDrop.pmmodule via thedraggableProof.planddraggableSubsets.plmacros.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.pmpackage 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.