Repository navigation
fix(edit): keep focus on the used move button when reordering options - #3937
AndyScherzinger merged 1 commit into
Conversation
88f9836 to
090221b
Compare
|
Tested on a Nextcloud 36 dev instance with a keyboard-only Playwright run: a multiple choice question with options A, B, C, the move menu of A opened with Enter, then Enter on the move buttons to go down, down, up, up. After each step the test checks the option order and which button has focus.
The PR passed all steps in four runs. ESLint and Prettier are clean on I rebased the branch onto @Chartman123 could you please review? Assisted by ClaudeCode:claude-opus-5-5 |
|
Looks good, the focus is kept correctly, but this still doesn't fix the visual glitch while moving: Bildschirmaufnahme.2026-11-20.130426.mp4 |
The move menu of an option is rendered inside the option's list item. While the options animate into their new order, every moving item gets a transform and so its own stacking context, and the items after the one with the open menu were painted over the menu. Lift the list item above its siblings while its menu is open. Ref: nextcloud#3937 (comment) Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The ranked list that respondents reorder has its own move menu with the same problems the option editor had: focus went to the item wrapper instead of the button, and the open menu was painted over by the following items while they animated into their new order. It also looked the move buttons up by position in refs that Vue keeps in mount order, so after a reorder it could focus another item's button. Look them up by option id instead, share the focus handling with the option editor, and lift the item with the open menu above its siblings. Ref: nextcloud#3937 (comment) Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
|
@Chartman123 thanks for the video. The menu is rendered inside its option's list item, and while the options animate into their new order each moving item gets its own stacking context, so the items below painted over the open menu. 97a9cb6 lifts the item with the open menu above its siblings. The ranked list in the respondent view had the same three issues, so 93411db covers it too: the same layering fix, the same focus fix (now shared in @bhardwajhimanshu2515 I pushed both commits to your branch, so please pull before pushing again. |
After an option is moved, the move-up/move-down buttons change their disabled state, NcActions re-renders and then moves focus to its first action unless one of its items is marked active. The previous code also focused the action's <li> wrapper instead of its button. Focus the button and mark its item active, so focus stays on the button that was used (or the other one once the option reaches the top or bottom). The move menu is rendered inside the option's list item. While the options animate into their new order, every moving item gets a transform and so its own stacking context, and the items after the one with the open menu were painted over the menu. Lift the list item above its siblings while its menu is open. The ranked list that respondents reorder in a ranking question had the same two problems and gets the same fixes. It also looked the move buttons up by position in refs that Vue keeps in mount order, so after a reorder it could focus another item's button; look them up by option id instead. The focus handling is shared in FocusActionItem.ts. Fixes nextcloud#2595 Co-authored-by: Himanshu Bhardwaj <bhardwajhimanshu2515@gmail.com> Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Himanshu Bhardwaj <bhardwajhimanshu2515@gmail.com> Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
93411db to
f670d5a
Compare
|
@bhardwajhimanshu2515 I squashed the PR into a single commit (f670d5a), with you as co-author and your sign-off kept. If you have a local copy of the branch, please reset it before pushing again: |
|
/backport to stable5.4 |
|
/backport to stable5.4 |
|
The backport to # Switch to the target branch and update it
git checkout stable5.4
git pull origin stable5.4
# Create the new backport branch
git checkout -b backport/3937/stable5.4
# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick f670d5a8
# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/3937/stable5.4Error: Failed to create pull request: Validation Failed: {"resource":"PullRequest","code":"custom","message":"A pull request already exists for nextcloud:backport/3937/stable5.4."} - https://docs.github.com/rest/pulls/pulls#create-a-pull-request Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports. |
Fixes #2595
Cause. After an option is moved, the move-up/move-down buttons change their
disabledstate, soNcActionsre-renders and, in a$nextTick, moves focus to its first action unless one of its items carries theactiveclass.focusButton()also calledfocus()on the action's<li>wrapper (NcActionButton's root), which is not focusable. Result: after "Move option down" focus jumped to "Move option up".The open menu also briefly disappeared while moving: it is rendered inside its option's list item, and while the options animate into their new order each moving item gets its own stacking context, so the items below painted over the menu.
Fix.
focusButton()now focuses the<button>inside the action and marks its itemactive, the same thingNcActionsdoes when it focuses an action itself. Focus stays on the button that was used, or moves to the other one when the option reaches the top or bottom. This now lives insrc/utils/FocusActionItem.ts.AnswerInput.vueand is covered by the first two fixes.Testing. I couldn't run a Nextcloud instance here, so I reproduced it with a minimal page using the same
@nextcloud/vueNcActions/NcActionButtonsetup (keyed list, menu container inside the row) and Playwright:For the menu layering and the ranking fixes: open the move menu of an option (checkboxes, radio buttons, dropdown and ranking in the editor, and a ranked item when answering a ranking question) and move it up and down several times. The menu should stay visible during the animation and focus should stay on the used button. This was tested on a live Nextcloud 36 instance with a form containing all four question types.
eslintpasses for the changed files,npm run buildsucceeds, andnpm run typecheckshows the same pre-existing errors before and after.🤖 AI (if applicable)