You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pi...@apache.org on 2018/12/14 15:41:26 UTC

[royale-asjs] branch bugfix/issue_353_double_dispatch_of_change_event_in_Jewel_List created (now 6044bd2)

This is an automated email from the ASF dual-hosted git repository.

piotrz pushed a change to branch bugfix/issue_353_double_dispatch_of_change_event_in_Jewel_List
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git.


      at 6044bd2  Jewel: Fix double dispatch of "change" event in List

This branch includes the following new commits:

     new 6044bd2  Jewel: Fix double dispatch of "change" event in List

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[royale-asjs] 01/01: Jewel: Fix double dispatch of "change" event in List

Posted by pi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

piotrz pushed a commit to branch bugfix/issue_353_double_dispatch_of_change_event_in_Jewel_List
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 6044bd2c02a719d4c954f61f41227a2aaa2dfbba
Author: Piotr Zarzycki <pi...@gmail.com>
AuthorDate: Fri Dec 14 16:41:12 2018 +0100

    Jewel: Fix double dispatch of "change" event in List
    
    Change event was disptached from ArrayListSelectionModel in order to discover programatic change of changed selectedIndex and selectedItem. Following commit will introduce issue where components DropDownList and ComboBox won't be able to discover whether user programmatically change properties selectedIndex or selectedItem. (reference #353)
---
 .../main/royale/org/apache/royale/jewel/ComboBox.as | 20 --------------------
 .../royale/org/apache/royale/jewel/DropDownList.as  | 19 -------------------
 .../src/main/royale/org/apache/royale/jewel/List.as | 21 ---------------------
 .../jewel/beads/models/ArrayListSelectionModel.as   |  5 -----
 4 files changed, 65 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
index f9f704b..a479008 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
@@ -74,7 +74,6 @@ package org.apache.royale.jewel
 			super();
 
             typeNames = "jewel combobox";
-            addEventListener('beadsAdded', setupModelChangeListener);
 		}
 
 		/**
@@ -181,24 +180,5 @@ package org.apache.royale.jewel
 			}
 			return presModel;
 		}
-
-        /**
-         * @royaleignorecoercion org.apache.royale.events.IEventDispatcher;
-		 * @royaleignorecoercion org.apache.royale.jewel.beads.models.IJewelSelectionModel;
-         */
-        private function setupModelChangeListener():void{
-            removeEventListener('beadsAdded', setupModelChangeListener);
-            IEventDispatcher(model).addEventListener('change', modelChangeDispatcher);
-            IJewelSelectionModel(model).dispatchChangeOnDataProviderChange = true;
-        }
-
-        private var respondingToProgrammaticChange:Boolean;
-
-        private function modelChangeDispatcher(event:Event):void{
-            //handles re-dispatching for programmatic changes
-            respondingToProgrammaticChange = true;
-            dispatchEvent(new Event("change"));
-            respondingToProgrammaticChange = false;
-        }
 	}
 }
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/DropDownList.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/DropDownList.as
index 597fe4f..7d2b171 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/DropDownList.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/DropDownList.as
@@ -83,7 +83,6 @@ package org.apache.royale.jewel
 		{
             super();
             typeNames = "jewel dropdownlist";
-            addEventListener('initComplete', setupModelChangeListener);
 		}
 
         protected var _dropDown:Select;
@@ -288,29 +287,11 @@ package org.apache.royale.jewel
         }
 
         /**
-         * @royaleignorecoercion org.apache.royale.events.IEventDispatcher;
-         */
-        private function setupModelChangeListener(event:Event):void{
-            removeEventListener('initComplete', setupModelChangeListener);
-            IEventDispatcher(model).addEventListener('change', modelChangeDispatcher);
-        }
-
-        private var respondingToProgrammaticChange:Boolean;
-
-        private function modelChangeDispatcher(event:Event):void{
-            //handles re-dispatching for programmatic changes
-            respondingToProgrammaticChange = true;
-            dispatchEvent(new Event("change"));
-            respondingToProgrammaticChange = false;
-        }
-
-        /**
          * @royaleignorecoercion HTMLSelectElement
          */
         COMPILE::JS
         protected function changeHandler(event:Event):void
         {
-            if (respondingToProgrammaticChange) return;
             var index:int = (element as HTMLSelectElement).selectedIndex;
 
             var ddModel:IDropDownListModel = model as IDropDownListModel;
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/List.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/List.as
index 11091c7..14fb311 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/List.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/List.as
@@ -85,7 +85,6 @@ package org.apache.royale.jewel
 		{
 			super();
             typeNames = "jewel list";
-            addEventListener('initComplete', setupModelChangeListener);
 		}
 
 		/**
@@ -233,25 +232,5 @@ package org.apache.royale.jewel
 			}
 			return presModel;
 		}
-
-
-        /**
-         * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
-		 * @royaleignorecoercion org.apache.royale.jewel.beads.models.IJewelSelectionModel
-         */
-        private function setupModelChangeListener(event:Event):void{
-            removeEventListener('initComplete', setupModelChangeListener);
-            IEventDispatcher(model).addEventListener('change', modelChangeDispatcher);
-			IJewelSelectionModel(model).dispatchChangeOnDataProviderChange = true;
-        }
-
-        private var respondingToProgrammaticChange:Boolean;
-
-        private function modelChangeDispatcher(event:Event):void{
-            //handles re-dispatching for programmatic changes
-            respondingToProgrammaticChange = true;
-            dispatchEvent(new Event("change"));
-            respondingToProgrammaticChange = false;
-        }
    	}
 }
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/ArrayListSelectionModel.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/ArrayListSelectionModel.as
index 99689d2..1533698 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/ArrayListSelectionModel.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/models/ArrayListSelectionModel.as
@@ -132,8 +132,6 @@ package org.apache.royale.jewel.beads.models
                 dispatchEvent(new Event("selectedItemChanged"));
             if (oldIndex != _selectedIndex)
                 dispatchEvent(new Event("selectedIndexChanged"));
-			if (_dispatchChangeOnDataChange && (itemChanged || oldIndex != _selectedIndex))
-                dispatchEvent(new Event("change"));
 		}
 
 		private var _selectedIndex:int = -1;
@@ -199,9 +197,6 @@ package org.apache.royale.jewel.beads.models
             if ( oldItem != _selectedItem)
                 dispatchEvent(new Event("selectedItemChanged"));
             dispatchEvent(new Event("selectedIndexChanged"));
-            if (!_processingInteractiveChange) {
-                dispatchEvent(new Event("change"));
-            }
 		}
 
         /**