Closed
Bug 1291835
Opened 8 years ago
Closed 8 years ago
The last search engine can be removed using the Delete key
Categories
(Firefox :: Settings UI, defect, P2)
Firefox
Settings UI
Tracking
()
VERIFIED
FIXED
Firefox 51
People
(Reporter: nohamelin, Assigned: claas)
References
Details
Attachments
(1 file, 3 obsolete files)
3.27 KB,
patch
|
florian
:
review+
|
Details | Diff | Splinter Review |
For the search pane of about:preferences, bug 1264475 lets to remove a search engine via keyboard besides the "Remove" button, but it lets remove all the search engines, something that it's not supported and it's not possible using the button.
Comment 1•8 years ago
|
||
I guess we could add a test for document.getElementById("removeEngineButton").disabled before handling the key press. Claas, is this something you would be interested in fixing?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(mozilla)
OS: Linux → All
Hardware: x86 → All
Assignee | ||
Comment 2•8 years ago
|
||
Florian, thanks for the ping, I am interested and will provide a fix.
Assignee: nobody → mozilla
Status: NEW → ASSIGNED
Flags: needinfo?(mozilla)
Assignee | ||
Updated•8 years ago
|
status-firefox50:
--- → affected
status-firefox51:
--- → affected
Assignee | ||
Comment 3•8 years ago
|
||
Attachment #8777930 -
Flags: review?(florian)
Comment 4•8 years ago
|
||
Comment on attachment 8777930 [details] [diff] [review] Prevent last search engine from being removed Review of attachment 8777930 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for taking care of this! ::: browser/components/preferences/in-content/search.js @@ +382,5 @@ > }, > > removeEngine: function ES_removeEngine(aEngine) { > + if (this._engines.length == 1) { > + throw new Error("Cannot remove last engine!"); This seems like a nice sanity check to add, but I don't think pressing a keyboard shortcut should produce an error in the console (it's user error, not something broken in the software), so I think we should also add a check in onTreeKeyPress, eg. !document.getElementById("removeEngineButton").disabled
Attachment #8777930 -
Flags: review?(florian) → feedback+
Assignee | ||
Comment 5•8 years ago
|
||
Attachment #8778373 -
Flags: review?(florian)
Assignee | ||
Comment 6•8 years ago
|
||
Thanks for the review. To avoid coupling the keyboard behaviour to the button, I chose to extract a getter `EngineView#isLastRemainingEngineSelected`.
Comment 7•8 years ago
|
||
Comment on attachment 8777930 [details] [diff] [review] Prevent last search engine from being removed (in the future, please mark the previous version as obsolete when attaching a new one. Including a version number in the patch's description also helps)
Attachment #8777930 -
Attachment is obsolete: true
Comment 8•8 years ago
|
||
Comment on attachment 8778373 [details] [diff] [review] Prevent last search engine from being removed Review of attachment 8778373 [details] [diff] [review]: ----------------------------------------------------------------- One trivial comment, looks good otherwise. ::: browser/components/preferences/in-content/search.js @@ +489,5 @@ > isCheckBox: function(index, column) { > return column.id == "engineShown"; > }, > > + get isLastRemainingEngineSelected() { I would prefer this to be a function to be consistent with the isCheckBox immediately above.
Attachment #8778373 -
Flags: review?(florian) → feedback+
Updated•8 years ago
|
Priority: -- → P2
Assignee | ||
Comment 9•8 years ago
|
||
Assignee | ||
Updated•8 years ago
|
Attachment #8778373 -
Attachment is obsolete: true
Assignee | ||
Comment 10•8 years ago
|
||
Comment on attachment 8779560 [details] [diff] [review] Prevent last search engine from being removed I have changed `isLastRemainingEngineSelected` to be a function rather than a getter. Note: I use `hg bzexport` to submit my patches. It seems as if it strips the bug number from the attachment description while leaving the description in the bug itself intact. If it's really necessary to have the bug number in the attachment description, the bzexport behavior should be changed. Also, I used `hg bzexport -e` with my second patch with does not allow to mark the previous patch as obsolete, while `hg bzexport -i` does, and I didn't verify that, but will in the feature.
Attachment #8779560 -
Flags: review?(florian)
Comment 11•8 years ago
|
||
Comment on attachment 8779560 [details] [diff] [review] Prevent last search engine from being removed Review of attachment 8779560 [details] [diff] [review]: ----------------------------------------------------------------- Looks great except for a coding style detail I should have noticed before. (In reply to Claas Augner [:claas] from comment #10) > Note: I use `hg bzexport` to submit my patches. It seems as if it strips the > bug number from the attachment description while leaving the description in > the bug itself intact. If it's really necessary to have the bug number in > the attachment description, the bzexport behavior should be changed. The bug number in the attachment description wouldn't help. It's a patch version that should go there. Eg. "Patch v1", "Patch v2", etc. > Also, I used `hg bzexport -e` This lets you edit the description. > with does not allow to mark the > previous patch as obsolete, while `hg bzexport -i` does Without option or with the -e option, hg bzexport will mark the previous version of the patch as obsolete if it has the same patch name. Your first attachment here had "1291835-last-search-engine" as the name, the second one had "bug-1291835-last-search-engine". ::: browser/components/preferences/in-content/search.js @@ +224,5 @@ > (!isMac && aEvent.keyCode == KeyEvent.DOM_VK_F2)) { > tree.startEditing(index, tree.columns.getLastColumn()); > } else if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE || > + isMac && aEvent.shiftKey && aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE > + && !gEngineView.isLastRemainingEngineSelected()) { I'm sorry I missed this last time: - we usually keep the operators at the end of the line. - when mixing || and && in the same test, especially when things are slit on multiple lines, we put parentheses around the && parts, and the next line is indented with one more space. Here the result would be: } else if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE || (isMac && aEvent.shiftKey && aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE && !gEngineView.isLastRemainingEngineSelected())) {
Attachment #8779560 -
Flags: review?(florian) → feedback+
Reporter | ||
Comment 12•8 years ago
|
||
> + isLastRemainingEngineSelected: function() {
> + return this.selectedIndex == -1 || this.lastIndex == 0;
> + },
By the way, the name of this function doesn't match really with its definition.
Comment 13•8 years ago
|
||
(In reply to Carlos [nohamelin] from comment #12) > > + isLastRemainingEngineSelected: function() { > > + return this.selectedIndex == -1 || this.lastIndex == 0; > > + }, > > By the way, the name of this function doesn't match really with its > definition. Do you have a better suggestion? :-)
Assignee | ||
Comment 14•8 years ago
|
||
(In reply to Carlos [nohamelin] from comment #12) > > + isLastRemainingEngineSelected: function() { > > + return this.selectedIndex == -1 || this.lastIndex == 0; > > + }, > > By the way, the name of this function doesn't match really with its > definition. Thanks for pointing this out: it also returns true if no engine is selected at all. Therefore I suppose it'd be better to name it "isEngineSelectedAndRemovable" (inversing its return value): > + isEngineSelectedAndRemovable: function() { > + return this.selectedIndex != -1 && this.lastIndex != 0; > + },
Assignee | ||
Comment 15•8 years ago
|
||
If you're busy with your PTO, I'd appreciate if you could forward this to anybody else. Thanks.
Attachment #8782577 -
Flags: review?(florian)
Assignee | ||
Updated•8 years ago
|
Attachment #8779560 -
Attachment is obsolete: true
Updated•8 years ago
|
Attachment #8782577 -
Flags: review?(florian) → review+
Updated•8 years ago
|
Keywords: checkin-needed
Comment 16•8 years ago
|
||
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/fx-team/rev/095ec4971ffb Prevent last search engine from being removed. r=florian
Keywords: checkin-needed
Comment 17•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/095ec4971ffb
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 51
Comment 18•8 years ago
|
||
I have reproduced this bug with Nightly 51.0a1 (2016-08-03) on Windows 7 , 64 Bit ! This bug's fix is verified with latest Aurora Build ID 20161005004013 User Agent Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0
Updated•8 years ago
|
Flags: qe-verify+
Comment 19•7 years ago
|
||
I've reproduced the initial issue on Windows 7 x64 using Firefox 50.0.2. Verified fixed on Windows 7 x64, Mac OSX 10.12 and Ubuntu 14.04 x64 using Firefox 51 Beta 8 (buildID: 20161215085501).
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•