summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Voborník <pvoborni@redhat.com>2012-02-23 16:16:23 +0100
committerPetr Vobornik <pvoborni@redhat.com>2012-02-29 13:07:22 +0100
commit6e6f24747e6ad384c956c952373e4084552a7e8d (patch)
tree852128ee72d6801dff7eb58c5599a9ec74e72c3a
parentd9f92712bce427e0ae0e84c43df3b0d1e4f6cc43 (diff)
downloadfreeipa.git-6e6f24747e6ad384c956c952373e4084552a7e8d.tar.gz
freeipa.git-6e6f24747e6ad384c956c952373e4084552a7e8d.tar.xz
freeipa.git-6e6f24747e6ad384c956c952373e4084552a7e8d.zip
Fixed selection of single value in combobox
When editable combobox had only one option and input field was cleared, the option couldn't be selected if it was selected before. This patch adds click handler to option elements. The handler calls select_on_change. When different option is selected select_on_change is executed twice. To avoid duplicate call of value_changed an open state of option area is checked. In first pass the area will be closed so it won't be executed in second. When selected option is clicked, only onclick handler is processed. This patch assumes that select event will be processed before click event. https://fedorahosted.org/freeipa/ticket/2070
-rw-r--r--install/ui/widget.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 0ebc82d0..642d3250 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -2144,14 +2144,7 @@ IPA.combobox_widget = function(spec) {
name: 'list',
size: that.size,
style: 'width: 100%',
- change: function() {
- var value = $('option:selected', that.list).val();
- that.input.val(value);
- IPA.select_range(that.input, 0, 0);
-
- that.close();
- that.value_changed.notify([[value]], that);
- }
+ change: that.select_on_change
}).appendTo(div);
if (that.undo) {
@@ -2161,6 +2154,18 @@ IPA.combobox_widget = function(spec) {
that.create_error_link(container);
};
+ that.select_on_change = function() {
+
+ if (!that.is_open()) return;
+
+ var value = $('option:selected', that.list).val();
+ that.input.val(value);
+ IPA.select_range(that.input, 0, 0);
+
+ that.close();
+ that.value_changed.notify([[value]], that);
+ };
+
that.open = function() {
if (!that.read_only)
that.list_container.css('visibility', 'visible');
@@ -2281,7 +2286,8 @@ IPA.combobox_widget = function(spec) {
that.create_option = function(label, value) {
return $('<option/>', {
text: label,
- value: value
+ value: value,
+ click:that.select_on_change
}).appendTo(that.list);
};