                 
                 clickedObject = clickedObject.parent;
             }
-                        
+            
             if (!mouseDownInsideComponent) {                
-                restoreEnteredTextAndHidePopUp(!_completionAccepted);
-            }
-        }
-                                    
+                showPreviousTextAndHidePopUp(!_completionAccepted);
+            }
+        }
+        
+        private function onAddedToStage(event : Event) : void {            
+            focusManager.addEventListener(FlexEvent.FLEX_WINDOW_ACTIVATE, onFlexWindowActivate);
+        }
+        
+        private function onFlexWindowActivate(event : FlexEvent) : void {
+            /* reset lastFocus value to prevent shifting focus 
+            to previously selected component
+            */
+            (focusManager as FocusManager).lastFocus = null;                        
+        }
+        
         private var _collection : ArrayCollection = new ArrayCollection();
-    
+        
         private var _completionAccepted : Boolean;
         
         private var _dataProviderChanged : Boolean;        
-                
+        
         private var _enteredText : String = "";
         
         private var _labelField : String;
         
         private var _labelFunction : Function;
         
-        private var _previouslyEnteredText : String = "";
+        private var _previouslyDisplayedText : String = "";
         
         private var _searchMode : String = SearchModes.INFIX_SEARCH;
         

     */
    [Style(name="highlightBackgroundColor", type="uint", format="Color", inherit="yes", theme="spark")]
    
	[Event (name="change", type="com.jabbypanda.event.InputAssistEvent")]		
	public class InputAssist extends SkinnableComponent {
		                
        [Bindable]
        public var maxRows : Number = 6;
        

            this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
            dataProvider = null;
        }        
        
        [Bindable]
        public function set dataProvider(value:Object) : void {
            if (value is Array) {
                _collection = new ArrayCollection(value as Array);
            }
            else if (value is ArrayCollection) {
                _collection = value as ArrayCollection;                
            } else {
                _collection = new ArrayCollection();
            }
            
            if (isOurFocus(this.getFocus())) {
                filterData();
            }
            
            _dataProviderChanged = true;
            invalidateProperties(); 
        }
        
        public function get dataProvider() : Object {
            return _collection; 
        }		                
        
        public function set searchMode(searchMode : String) : void {            
            _searchMode = searchMode; 
