Closed Bug 322155 Opened 20 years ago Closed 20 years ago

if the only focusable elements in a dialog are the buttons, focus the default button on load

Categories

(Toolkit :: UI Widgets, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla1.8.1

People

(Reporter: Gavin, Assigned: Gavin)

References

()

Details

(Keywords: fixed1.8.1)

Attachments

(1 file, 1 obsolete file)

Many users of the dialog binding want the default button focused, mostly to ensure that on Windows/Linux, hitting enter after the dialog appears triggers the button. Currently this requires a .focus() onLoad, since the dialog currently focuses the first focusable element, which for many cases is another button. I propose changing the behavior so that dialogs whose only focusable elements are the buttons default to focusing the default button. This would eliminate the need for onload "getButton(XX).focus()" calls in many dialogs (see URL for some examples). Toolkit patch coming, I'll patch xpfe too if there's agreement that this is desired.
Attached patch patch (obsolete) — — Splinter Review
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla1.9alpha1
Shouldn't the URL just search for the "accept" button? When I do that, there are only nine entries: /calendar/sunbird/base/content/aboutDialog.js /toolkit/mozapps/downloads/content/downloadProperties.js /browser/base/content/aboutDialog.js /browser/base/content/pageReport.js In these cases a non-button appears to be taking the focus. /xpinstall/res/content/xpistatus.js The focus is set after XPI install completes. /security/manager/pki/resources/content/newserver.js This looks like a badly designed dialog, and the View Certificate non-dialog button should be put on extra2 instead, which would resolve the issue. /security/manager/pki/resources/content/serverCrlNextupdate.js I guess this one depends on the platform - it probably works fine on Windows. /security/manager/pki/resources/content/serverCertExpired.js /security/manager/pki/resources/content/domainMismatch.js OK, so these two appear to be valid on all platforms.
Attachment #207376 - Flags: second-review?(neil.parkwaycc.co.uk)
Attachment #207376 - Flags: first-review?(bugs.mano)
Neil and I discussed this on IRC, I mentioned that there are other cases that aren't caught by that regexp. Neil mentioned that maybe having an attribute to indicate the button to focus would be useful, but then I can't think of a situation where that button would not be the defaultButton. Bug 213207 is an example of a bug that would be easier to fix with this change.
Whiteboard: [patch-r?]
Target Milestone: mozilla1.9alpha1 → mozilla1.8.1
Comment on attachment 207376 [details] [diff] [review] patch >- var focusInit = >- function() { >+ function dialog_postLoadInit(aDialog) { No need to rename this, plus aDialog is unused, so the above becomes "function focusInit() {" and the change below is reverted: >- setTimeout(focusInit, 0); >+ setTimeout(dialog_postLoadInit, 0, 0);
Attachment #207376 - Flags: second-review?(neil) → second-review+
Attached patch updated patch — — Splinter Review
Attachment #207376 - Attachment is obsolete: true
Attachment #207376 - Flags: first-review?(bugs.mano)
Whiteboard: [patch-r?]
mozilla/toolkit/content/widgets/dialog.xml 1.28 mozilla/xpfe/global/resources/content/bindings/dialog.xml 1.38
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Attachment #214905 - Flags: approval-branch-1.8.1?(neil)
Attachment #214905 - Flags: approval-branch-1.8.1?(neil) → approval-branch-1.8.1+
Whiteboard: [checkin needed (1.8 branch)]
Gavin, wanna land this on branch? Thanks.
(In reply to comment #7) > Gavin, wanna land this on branch? Thanks. The branch is still closed for Firefox alpha 2. I will land this once it opens, which will probably be later today.
mozilla/xpfe/global/resources/content/bindings/dialog.xml 1.34.4.3 mozilla/toolkit/content/widgets/dialog.xml 1.25.2.7
Keywords: fixed1.8.1
Whiteboard: [checkin needed (1.8 branch)]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: