diff --git a/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp b/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp index 3d5c6040f0a..7eecabb3756 100644 --- a/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp +++ b/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp @@ -646,9 +646,9 @@ NS_IMETHODIMP nsAbAutoCompleteSession::OnStartLookup(const PRUnichar *uSearchStr status = nsIAutoCompleteStatus::matchFound; if (addedDefaultItem) { - // always make the first search result the default item. - // if we dont' have any matches then use pos 0 which is the default item.... - results->SetDefaultItemIndex(nbrOfItems > 1 ? 1 : 0); + // If we have at least one REAL match then make it the default item. If we don't have any matches, + // just the default domain, then don't install a default item index on the widget. + results->SetDefaultItemIndex(nbrOfItems > 1 ? 1 : -1); } else results->SetDefaultItemIndex(0); diff --git a/xpfe/components/autocomplete/resources/content/autocomplete.xml b/xpfe/components/autocomplete/resources/content/autocomplete.xml index 0f00355d6ac..df227953ec5 100644 --- a/xpfe/components/autocomplete/resources/content/autocomplete.xml +++ b/xpfe/components/autocomplete/resources/content/autocomplete.xml @@ -279,6 +279,7 @@ null null null + false @@ -668,10 +676,26 @@ // do nothing } else if (this.forceComplete && (this.mNeedToComplete || aForceComplete)) { var defaultSession = this.getDefaultSession(); + + // we want to use the default item index for the first session which gave us a valid + // default item index... + + for (var name in this.mLastResults) { + var results = this.mLastResults[name]; + if (results && results.items.Count() > 0 && results.defaultItemIndex != -1) + { + defaultSession = name; + break; + } + } + if (defaultSession) { var results = this.mLastResults[defaultSession]; - if (results && !this.noMatch && results.defaultItemIndex != -1) + if (results && !this.noMatch) + if (results.defaultItemIndex != -1) this.value = this.getSessionValueAt(defaultSession, results.defaultItemIndex); + else + this.value = this.getSessionValueAt(defaultSession, 0); // preselect the first one... } } @@ -908,15 +932,19 @@ +