From 71c72c396c703bc84c4ffcf686f0ce9c5de0b7d9 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Wed, 10 Sep 2008 21:47:50 +0000 Subject: [PATCH] Fixed list selectors' behaviour during search. --- includes/ui/ui_lists.inc | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 86968c9..ddcd100 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -84,7 +84,6 @@ $opts = array( // default options $limit = ''; if (isset($_POST[$select_submit])) { - if ($by_id) $txt = $_POST[$name]; if (!$opts['async']) @@ -98,6 +97,7 @@ $opts = array( // default options $rel = "rel='$search_box'"; // set relation to list if ($opts['search_submit']) { if (isset($_POST[$search_submit])) { + $selected_id = ''; // ignore selected_id while search if (!$opts['async']) $Ajax->activate('_page_body'); else @@ -139,10 +139,13 @@ $opts = array( // default options $descr = $opts['format']==null ? $contact_row[1] : call_user_func($opts['format'], $contact_row); $sel = ''; - if ((string)($selected_id) === $value) { + if (get_post($search_submit) && ($txt === $value)) { + $selected_id = $value; + } + if ((string)($selected_id) === $value) { $sel = 'selected'; $found = $value; - } + } if ($first_id === false) { $first_id = $value; $first_opt = $descr; @@ -167,8 +170,8 @@ $opts = array( // default options $_POST[$name] = $selected_id; if ($by_id && $search_box != false) { - $txt = $_POST[$name]; - $Ajax->addUpdate($name, $search_box, $txt); + $txt = $found; + $Ajax->addUpdate($name, $search_box, $txt ? $txt : ''); } $selector = "\n"; @@ -212,6 +215,15 @@ $opts = array( // default options return $str; } + +/* + Helper function. + Returns true if selector $name is subject to update. +*/ +function list_updated($name) +{ + return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']); +} //---------------------------------------------------------------------------------------------- // Universal array combo generator // $items is array of options 'value' => 'description' -- 2.30.2