URL: https://github.com/freeipa/freeipa/pull/368
Author: pvomacka
 Title: #368: WebUI: fix incorrect behavior of ESC button on combobox     
Action: opened

PR body:
"""
When combobox is opened then ESC key should close it. There was a bug
that ESC key closed also the dialog. It was caused by bad keyboard event
handling. The CB was closed by keydown event and the dialog by keyup.
    
Therefore the propagating of keyup and keydown event is stopped when CB
is opened (when the event is fired on CB element).
    
https://fedorahosted.org/freeipa/ticket/6388
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/368/head:pr368
git checkout pr368
From b719aa6b98d1706794ec570b539dc9198fe04905 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Wed, 4 Jan 2017 12:21:57 +0100
Subject: [PATCH 1/2] WebUI: add default on_cancel function in adder_dialog

Adder dialog is mixed with confirmation_mixin. That mixin calls on_cancel method
when closing dialog using ESC key. Previously the on_cancel method
was not defined, therefore dialog was not correctly closed. This was the root
cause of the bug, that adder dialog cannot be opened after closing it using ESC.

Now the default function for on_cancel is dialog.close. So dialog
is correctly closed.

https://fedorahosted.org/freeipa/ticket/6388
---
 install/ui/src/freeipa/add.js | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/install/ui/src/freeipa/add.js b/install/ui/src/freeipa/add.js
index 6221085..b93bd34 100644
--- a/install/ui/src/freeipa/add.js
+++ b/install/ui/src/freeipa/add.js
@@ -36,6 +36,8 @@ IPA.entity_adder_dialog = function(spec) {
 
     var that = IPA.dialog(spec);
 
+    that.on_cancel = that.close;
+
     IPA.confirm_mixin().apply(that);
 
     /** @property {string} method="add" API method for add command */

From 065a1db42f2b6000e0f54ecfebd65570facd7892 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Wed, 4 Jan 2017 12:28:55 +0100
Subject: [PATCH 2/2] WebUI: fix incorrect behavior of ESC button on combobox

When combobox is opened then ESC key should close it. There was a bug
that ESC key closed also the dialog. It was caused by bad keyboard event
handling. The CB was closed by keydown event and the dialog by keyup.

Therefore the propagating of keyup and keydown event is stopped when CB
is opened (when the event is fired on CB element).

https://fedorahosted.org/freeipa/ticket/6388
---
 install/ui/src/freeipa/widget.js | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 041eaa2..6159410 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -4611,7 +4611,7 @@ IPA.combobox_widget = function(spec) {
         that.list_container = $('<div/>', {
             'class': 'combobox-widget-list',
             css: { 'z-index': that.z_index, 'display':'none' },
-            keydown: that.on_list_container_keydown
+            keyup: that.on_list_container_keyup
         }).appendTo(that.input_container);
 
         var div = $('<div/>', {
@@ -4723,7 +4723,7 @@ IPA.combobox_widget = function(spec) {
         }
     };
 
-    that.on_list_container_keydown = function(e) {
+    that.on_list_container_keyup = function(e) {
         // close on ESCAPE and consume event to prevent unwanted
         // behaviour like closing dialog
         if (e.which == keys.ESCAPE) {
@@ -4756,11 +4756,16 @@ IPA.combobox_widget = function(spec) {
             e.preventDefault();
             that.select_next();
             that.list.focus();
+        } else if (key === keys.ESCAPE) {
+            e.stopPropagation();
         }
     };
 
     that.list_on_keydown = function(e) {
-        if (e.which === keys.TAB) {
+        if (e.which === keys.ESCAPE) {
+            e.stopPropagation();
+            return false;
+        } else if (e.which === keys.TAB) {
             e.preventDefault();
             if (that.searchable) {
                 that.filter.focus();
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to