buttons for reordering problems in a set details page - #3090
Conversation
|
I'm happy to defer to your recommendations here. I could withdraw this, or feed what you have described here to Claude. I probably won't directly intervene with coding changes myself on this one though. Whatever things here (and with the other PRs I've made today) that we can complete, it will affect the Accessibility Guide I'm trying to complete before the release. It's getting down to a pretty short list of known issues (as far as webwork2 goes, that is). |
|
We can perhaps go with this for now, and then change to what I was thinking of later when I have time to work on that. |
|
OK. I'll see what Claude can do for the smaller tweaks you identified. |
8737b32 to
726f2d4
Compare
|
The issues you found are at least mostly addressed now. The method I directed for the first issue (about overcrowding) is maybe not the best though. |
|
I find the "indent"/"outdent" terminology a bit ugly. Also, in a JITAR set it isn't really indentation. It is nesting, and in fact the wording everywhere else calls it nesting. |
|
There is another problem with this. Say problem 1 and 2 use the same file. Problem 2 will have an alert "This problem uses the same source file as number 1.". Then if I use the buttons to swap #1 with #2, now the new #1 still says "This problem uses the same source file as number 1.". I'm working on that. |
726f2d4 to
933857d
Compare
|
OK, the language (both user-facing and internal) is now about nest/denest instead of indent/outdent. Also I moved the alerts for "This problem uses the same source file as number 1." from the template to the javascript, so it can be recalculated as things move. This is probably already an issue with the current mouse-driven rearrangement tool. |
drgrice1
left a comment
There was a problem hiding this comment.
This is going to take some time to review and test properly. But here are some things I see at this point.
933857d to
2176f50
Compare
|
OK, those code changes are in. |
2176f50 to
c7d97d6
Compare
c7d97d6 to
0a3b2b9
Compare
drgrice1
left a comment
There was a problem hiding this comment.
I think this looks good at this point.
somiaj
left a comment
There was a problem hiding this comment.
Looks good.
One thing I noticed (no fix needed) is when you copy/paste the name of a pg file into another problem, the 'duplicate warning' message doesn't appear until the order of the problems is changed. Further if you edit the filename of a duplicate file to a unique thing, the warning doesn't get removed until the problems are reordered. Would it be worth also updating the duplicate messages when the filename of a problem is edited?
0a3b2b9 to
db7fcf3
Compare
This was fairly nontrivial. The top two lines of each problem's box use bootstrap grid, and then below that is a table with limited options for setting widths with bootstrap. But I like what I came up with better. See what you think. @somiaj For what you noticed, I did not want to add even listeners for edits to the text field. But it could be done in the future. |
db7fcf3 to
db07665
Compare
| container?.addEventListener('click', (e) => { | ||
| const button = e.target.closest('.psd_move_up, .psd_move_down, .psd_nest, .psd_denest'); | ||
| if (!button || button.disabled) return; | ||
|
|
||
| // Since focus stays on (or moves to another) reorder button after the click is handled below, the | ||
| // tooltip's own focus/hover triggers won't naturally hide it. Hide it explicitly so it doesn't get stuck. | ||
| bootstrap.Tooltip.getInstance(button)?.hide(); | ||
|
|
||
| if (button.classList.contains('psd_move_up')) moveItem(button, 'up'); | ||
| else if (button.classList.contains('psd_move_down')) moveItem(button, 'down'); | ||
| else if (button.classList.contains('psd_nest')) nestItem(button); | ||
| else denestItem(button); | ||
| }); |
There was a problem hiding this comment.
I just noticed this. It does not make sense that this click handler is on the container instead of directly on the buttons. That is not a good way to deal with this. This should be
| container?.addEventListener('click', (e) => { | |
| const button = e.target.closest('.psd_move_up, .psd_move_down, .psd_nest, .psd_denest'); | |
| if (!button || button.disabled) return; | |
| // Since focus stays on (or moves to another) reorder button after the click is handled below, the | |
| // tooltip's own focus/hover triggers won't naturally hide it. Hide it explicitly so it doesn't get stuck. | |
| bootstrap.Tooltip.getInstance(button)?.hide(); | |
| if (button.classList.contains('psd_move_up')) moveItem(button, 'up'); | |
| else if (button.classList.contains('psd_move_down')) moveItem(button, 'down'); | |
| else if (button.classList.contains('psd_nest')) nestItem(button); | |
| else denestItem(button); | |
| }); | |
| for (const button of document.querySelectorAll('.psd_move_up, .psd_move_down, .psd_nest, .psd_denest')) { | |
| button.addEventListener('click', () => { | |
| // Since focus stays on (or moves to another) reorder button after the click is handled below, the | |
| // tooltip's own focus/hover triggers won't naturally hide it. Hide it explicitly so it doesn't get stuck. | |
| bootstrap.Tooltip.getInstance(button)?.hide(); | |
| if (button.classList.contains('psd_move_up')) moveItem(button, 'up'); | |
| else if (button.classList.contains('psd_move_down')) moveItem(button, 'down'); | |
| else if (button.classList.contains('psd_nest')) nestItem(button); | |
| else denestItem(button); | |
| }); | |
| } |
It is really a hack to use a click event listener on the container and then find the button that was clicked in the listener, when really you want a click on the button. Note that you don't even need to check that the button is disabled with this because disabled buttons do not receive the click event at all.
There was a problem hiding this comment.
OK, this change is made (not yet pushed). I'm going to see if there's a quick way to address the spacing issues you saw. (Yes, the whole thing should be refactored. In my opinion, also replacing the table in the lower part.)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
db07665 to
15573e1
Compare
|
Pushed, with that click event listener change. Also with changes that keep the collapse button at the top row. However, at the tiny screen size (smaller than the sm breakpoint), there is not enough room for all the things you mentioned for a nested JITAR. So only below the sm breakpoint, I made the buttons narrower. Then it all fits. Even if it's JITAR with a wide number like 8.20.8. |
|
I think that is better, and good enough for now. |






When in the Set Details page, there will now be buttons on each problem to move a problem up/down in sequence. The mouse click-and-drag tool is still there, but these buttons give a keyboard accessible way to rearrange the problems.
If the set is a JITAR set, there are also buttons for indenting/outdenting problems.
Buttons are disabled when appropriate (like you can't move problem #1 up in the list).