File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ export function moveBlockToNotConflict(
8383 block : BlockSvg ,
8484 originalPosition : Coordinate ,
8585) {
86+ if ( block . workspace . RTL ) {
87+ originalPosition . x = block . workspace . getWidth ( ) - originalPosition . x ;
88+ }
8689 const workspace = block . workspace ;
8790 const snapRadius = config . snapRadius ;
8891 const bumpOffset = Coordinate . difference (
Original file line number Diff line number Diff line change @@ -157,6 +157,30 @@ suite('Clipboard', function () {
157157 ) ;
158158 } ) ;
159159
160+ test ( 'pasted blocks are bumped to not overlap in RTL' , function ( ) {
161+ this . workspace . dispose ( ) ;
162+ this . workspace = Blockly . inject ( 'blocklyDiv' , { rtl : true } ) ;
163+ const block = Blockly . serialization . blocks . append (
164+ {
165+ 'type' : 'controls_if' ,
166+ 'x' : 38 ,
167+ 'y' : 13 ,
168+ } ,
169+ this . workspace ,
170+ ) ;
171+ const data = block . toCopyData ( ) ;
172+
173+ const newBlock = Blockly . clipboard . paste ( data , this . workspace ) ;
174+ const oldBlockXY = block . getRelativeToSurfaceXY ( ) ;
175+ assert . deepEqual (
176+ newBlock . getRelativeToSurfaceXY ( ) ,
177+ new Blockly . utils . Coordinate (
178+ oldBlockXY . x - Blockly . config . snapRadius ,
179+ oldBlockXY . y + Blockly . config . snapRadius * 2 ,
180+ ) ,
181+ ) ;
182+ } ) ;
183+
160184 test ( 'pasted blocks are bumped to be outside the connection snap radius' , function ( ) {
161185 Blockly . serialization . workspaces . load (
162186 {
You can’t perform that action at this time.
0 commit comments