diff options
author | Tim Buschtöns | 2013-08-01 12:53:47 +0000 |
---|---|---|
committer | Tim Buschtöns | 2013-08-01 12:53:47 +0000 |
commit | b46230d2fcd27989cd9c9930d2d3d513f7f5e9aa (patch) | |
tree | 984d95bd0c38e9058aa6879a9d5c23f86fc21ac9 | |
parent | 49afb12a9ed2d237cb30fa4a45d3e698f24b36e7 (diff) | |
download | org.eclipse.rap.incubator.dropdown-b46230d2fcd27989cd9c9930d2d3d513f7f5e9aa.tar.gz org.eclipse.rap.incubator.dropdown-b46230d2fcd27989cd9c9930d2d3d513f7f5e9aa.tar.xz org.eclipse.rap.incubator.dropdown-b46230d2fcd27989cd9c9930d2d3d513f7f5e9aa.zip |
Fix DropDown layout when it appears while parent position is changing
If a the DropDown is made visible in the same request as the parent gets
a new position, the DropDown appears at the old position. This fixes the
issue.
-rw-r--r-- | bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js | 9 | ||||
-rw-r--r-- | tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js | 38 |
2 files changed, 47 insertions, 0 deletions
diff --git a/bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js b/bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js index 36fc87d..82d7ae1 100644 --- a/bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js +++ b/bundles/org.eclipse.rap.addons.dropdown/js/rwt/dropdown/DropDown.js @@ -72,6 +72,7 @@ this._.inMouseSelection = false; this._.events = createEventsMap(); this._.parent.addEventListener( "keypress", onTextKeyEvent, this ); + this._.parent.addEventListener( "flush", onTextFlush, this ); this._.grid._sendSelectionChange = bind( this, onSelection ); this._.grid.addEventListener( "keypress", onKeyEvent, this ); this._.grid.addEventListener( "mousedown", onMouseDown, this ); @@ -249,6 +250,7 @@ if( !this._.parent.isDisposed() ) { this._.parent.removeEventListener( "appear", onTextAppear, this ); this._.parent.removeEventListener( "keydown", onTextKeyEvent, this ); + this._.parent.removeEventListener( "flush", onTextFlush, this ); this._.parent.removeEventListener( "keypress", onTextKeyEvent, this ); this._.popup.destroy(); } @@ -415,6 +417,13 @@ } }; + var onTextFlush = function( event ) { + var changes = event.getData(); + if( this._.visibility && ( changes.top || changes.left || changes.width || changes.height ) ) { + renderLayout.call( this ); + } + }; + var onKeyEvent = function( event ) { switch( event.getKeyIdentifier() ) { case "Enter": diff --git a/tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js b/tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js index f32a0de..22f2d46 100644 --- a/tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js +++ b/tests/org.eclipse.rap.addons.dropdown.test/js/rwt/dropdown/DropDown_Test.js @@ -318,6 +318,37 @@ rwt.qx.Class.define( "rwt.dropdown.DropDown_Test", { assertEquals( 70, popup.getTop() ); }, + testShow_PositionsPopUpWhileParentIsInLayoutQueueForTop : function() { + widget.setTop( 50 ); + showDropDown(); + + assertEquals( 20, popup.getLeft() ); + assertEquals( 100, popup.getTop() ); + }, + + testShow_PositionsPopUpWhileParentIsInLayoutQueueForLeft : function() { + widget.setLeft( 20 ); + showDropDown(); + + assertEquals( 30, popup.getLeft() ); + assertEquals( 70, popup.getTop() ); + }, + + testShow_PositionsPopUpWhileParentIsInLayoutQueueForHeight : function() { + widget.setHeight( 50 ); + showDropDown(); + + assertEquals( 20, popup.getLeft() ); + assertEquals( 90, popup.getTop() ); + }, + + testShow_LayoutsPopUpWhileParentIsInLayoutQueueForWidth : function() { + widget.setWidth( 150 ); + showDropDown(); + + assertEquals( 150, popup.getWidth() ); + }, + testShow_SendsVisible : function() { showDropDown(); rwt.remote.Server.getInstance().send(); @@ -1052,6 +1083,13 @@ rwt.qx.Class.define( "rwt.dropdown.DropDown_Test", { // Succeeds by not crashing }, + testDestroy_DeregistersFlushListener : function() { + dropdown.destroy(); + widget.setTop( 45 ); + TestUtil.flush(); + // Succeeds by not crashing + }, + testDestroy_RemoveListenerDoesNotCrash : function() { var listener = function(){}; dropdown.addListener( "Selection", listener ); |