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
Родитель fc7c81fa58
Коммит a02dae3c60
3 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

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

Просмотреть файл

@ -233,7 +233,7 @@
<label crop="center" flex="1" class="tooltip-label"/> <label crop="center" flex="1" class="tooltip-label"/>
</tooltip> </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 #ifdef XP_WIN
# XXX bug 457997 # XXX bug 457997
noautohide="true" noautohide="true"

Просмотреть файл

@ -91,6 +91,13 @@ function test() {
ok(isOpen(), ok(isOpen(),
"panel is sticky after focusing the search field and releasing the Ctrl key"); "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 // blur the search field
EventUtils.synthesizeKey("VK_TAB", {}); EventUtils.synthesizeKey("VK_TAB", {});
isnot(document.activeElement, ctrlTab.searchField.inputField, isnot(document.activeElement, ctrlTab.searchField.inputField,
@ -98,6 +105,7 @@ function test() {
// advance selection and close panel // advance selection and close panel
EventUtils.synthesizeKey("VK_TAB", {}); EventUtils.synthesizeKey("VK_TAB", {});
EventUtils.synthesizeKey("VK_TAB", {});
EventUtils.synthesizeKey("VK_RETURN", {}); EventUtils.synthesizeKey("VK_RETURN", {});
ok(!isOpen(), ok(!isOpen(),
"Enter key closes the panel"); "Enter key closes the panel");