Repository navigation
fix: let enter press a dialog's default button as soon as it opens - #570
Merged
Merged
Conversation
Qt gives the keyboard to a popup itself when it opens, and keys go from the focused item to its parents, never into its children: the Enter handler on a dialog's content did not see the key until focus moved into the dialog. Qt 6.11's default button focus hid this on some opening paths only. PopupInitialFocus gives the content the keyboard each time the popup shows, before it fades in. The shared confirmation, the tag editor's question, the rename preview, Auto Number, the quit-time save failure and the quit wait use it. Tab, Escape, the closing guard and the current default button work as before. Closes #562
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.
What changes
When one of these dialogs opened, Enter did nothing until keyboard focus moved into the dialog, for example after pressing Tab:
Qt gives the keyboard to the popup itself. Keys go from the focused item to its parents and never into its children, so the Enter handler on the dialog's content (
DialogButtons.handleEnter) never saw the key. On Qt 6.11,DialogButtonBox.defaultButtongives the default button the focus, which hid the bug on some opening paths but not on others.A new shared component,
PopupInitialFocus, gives the dialog's content the keyboard each time the popup becomes visible. That happens before the fade-in, so an Enter pressed as the dialog appears reaches the content's handler. It uses only public API (Popup.visibleandItem.forceActiveFocus). Each affected dialog declares it next to itsPopupClosing.These behaviours are unchanged:
Dialogs without a primary button
Diagnostics, TagEditorStatusDetails and ItunesArtwork have no default button and no Enter handler. Enter still does nothing in them, by design. This PR does not touch them.
Tests
Each affected dialog is opened through its real trigger. The test then presses Enter right away, without moving focus first, and checks that the default action runs exactly once. It also checks that Enter during the closing fade does nothing more, that Escape at once cancels, and, for the two confirmations, that Tab reaches the buttons without leaving the dialog.
PreferencesSmokeTest::enterConfirmsAsSoonAsTheConfirmationShows(ConfirmDialog, through Clear in Diagnostics)ErrorsSmokeTest::enterRetriesAsSoonAsTheSaveFailureShowsTagEditorSmokeTest::enterAnswersTheTagEditorsQuestionAsSoonAsItShows(close, reload and save paths)TagEditorSmokeTest::enterKeepsWaitingOnceTheQuitWaitOffersIt(Enter does nothing before the choice appears, then presses Keep Waiting)TagEditorSmokeTest::enterNumbersTracksAsSoonAsAutoNumberShowsTagEditorSmokeTest::enterRenamesAsSoonAsThePreviewShowsWith the six dialogs reverted to main, all six tests fail at the focus check. With that check stubbed out as well, the Enter checks of four of them still fail. The confirmation and the tag editor question pass that run on Qt 6.11.2, because Qt focuses their default button on these paths.
The tests are session-independent: they use the existing smoke harness, which calls
TestSessionIsolation.h, runs offscreen and uses temporary user directories.Closes #562