         // if an editor is already up, close it without starting a new editor.
         if (itemEditorInstance)
         {
-            dataGrid.endItemEditorSession();
+            // if the user clicks outside the cell but we can't save the data,
+            // say, because the data was invalid, then cancel the save.
+            if (!dataGrid.endItemEditorSession())
+            {
+                dataGrid.endItemEditorSession(true);
+            }
             return;
         }
         

            
            if (restoreFocusableChildren)
            {
                dataGrid.hasFocusableChildren = saveDataGridHasFocusableChildren;

                if (dataGrid.scroller)
                    dataGrid.scroller.hasFocusableChildren = saveScrollerHasFocusableChildren;
            }
            
            itemEditorInstance = null;

                (editedItemRenderer == child || 
                     IUIComponent(editedItemRenderer).owns(DisplayObject(child)))));
    }
 
    /**
     *  @private
     * 
     *  Restore the focusable children flags.
     */ 
    private function restoreFocusableChildrenFlags():void
    {
        dataGrid.hasFocusableChildren = saveDataGridHasFocusableChildren;
        
        if (dataGrid.scroller)
            dataGrid.scroller.hasFocusableChildren = saveScrollerHasFocusableChildren;

    }
    
    //--------------------------------------------------------------------------
    //
