Bug 463299 - Hitting Esc when text was entered in the search box shouldn't close the all tabs / ctrl-tab panel. r=gavin

This commit is contained in:
Dão Gottwald 2008-11-06 20:20:34 +01:00
parent e14de76132
commit 9b54f9e4af
3 changed files with 13 additions and 4 deletions

View File

@ -434,7 +434,9 @@ var ctrlTab = {
onKeyPress: function ctrlTab__onKeyPress(event) {
var isOpen = this.isOpen;
if (isOpen && event.target == this.searchField)
if (isOpen &&
event.target == this.searchField &&
event.keyCode != event.DOM_VK_ESCAPE)
return;
if (isOpen) {
@ -615,8 +617,7 @@ var ctrlTab = {
case "keydown":
case "keyup":
if (event.target == this.searchField) {
if (event.keyCode == event.DOM_VK_RETURN ||
event.keyCode == event.DOM_VK_ESCAPE)
if (event.keyCode == event.DOM_VK_RETURN)
this.panel.focus();
} else {
// Manually consume the events, as the panel is open but doesn't

View File

@ -233,7 +233,7 @@
<label crop="center" flex="1" class="tooltip-label"/>
</tooltip>
<panel id="ctrlTab-panel" class="KUI-panel" hidden="true" norestorefocus="true"
<panel id="ctrlTab-panel" class="KUI-panel" hidden="true" norestorefocus="true" ignorekeys="true"
#ifdef XP_WIN
# XXX bug 457997
noautohide="true"

View File

@ -91,6 +91,13 @@ function test() {
ok(isOpen(),
"panel is sticky after focusing the search field and releasing the Ctrl key");
ctrlTab.searchField.value = "foo";
EventUtils.synthesizeKey("VK_ESCAPE", {});
is(ctrlTab.searchField.value, "",
"ESC key clears the search field");
ok(isOpen(),
"Clearing the search field with ESC keeps the panel open");
// blur the search field
EventUtils.synthesizeKey("VK_TAB", {});
isnot(document.activeElement, ctrlTab.searchField.inputField,
@ -98,6 +105,7 @@ function test() {
// advance selection and close panel
EventUtils.synthesizeKey("VK_TAB", {});
EventUtils.synthesizeKey("VK_TAB", {});
EventUtils.synthesizeKey("VK_RETURN", {});
ok(!isOpen(),
"Enter key closes the panel");