@@ -196,44 +196,57 @@ export default function Canvas() {
196196
197197 if ( ! e . isPrimary ) return ;
198198
199+ let locked = false ;
200+ let prevCoords = { prevX : 0 , prevY : 0 } ;
201+
199202 if ( type === ObjectType . TABLE ) {
200203 const table = tables . find ( ( t ) => t . id === id ) ;
204+ locked = table . locked ;
205+
201206 setGrabOffset ( {
202207 x : table . x - pointer . spaces . diagram . x ,
203208 y : table . y - pointer . spaces . diagram . y ,
204209 } ) ;
205- setDragging ( ( prev ) => ( {
206- ...prev ,
207- id,
208- element : type ,
209- prevX : table . x ,
210- prevY : table . y ,
211- } ) ) ;
210+ prevCoords = { prevX : table . x , prevY : table . y } ;
212211 } else if ( type === ObjectType . AREA ) {
213212 const area = areas . find ( ( t ) => t . id === id ) ;
213+ locked = area . locked ;
214+
214215 setGrabOffset ( {
215216 x : area . x - pointer . spaces . diagram . x ,
216217 y : area . y - pointer . spaces . diagram . y ,
217218 } ) ;
218- setDragging ( ( prev ) => ( {
219- ...prev ,
220- id,
221- element : type ,
222- prevX : area . x ,
223- prevY : area . y ,
224- } ) ) ;
219+ prevCoords = { prevX : area . x , prevY : area . y } ;
225220 } else if ( type === ObjectType . NOTE ) {
226221 const note = notes . find ( ( t ) => t . id === id ) ;
222+ locked = note . locked ;
223+
227224 setGrabOffset ( {
228225 x : note . x - pointer . spaces . diagram . x ,
229226 y : note . y - pointer . spaces . diagram . y ,
230227 } ) ;
228+ prevCoords = { prevX : note . x , prevY : note . y } ;
229+ }
230+
231+ if ( locked ) {
232+ setPanning ( {
233+ isPanning : true ,
234+ panStart : transform . pan ,
235+ cursorStart : pointer . spaces . screen ,
236+ } ) ;
237+ pointer . setStyle ( "grabbing" ) ;
238+ } else {
231239 setDragging ( ( prev ) => ( {
232240 ...prev ,
233241 id,
234242 element : type ,
235- prevX : note . x ,
236- prevY : note . y ,
243+ ...prevCoords ,
244+ } ) ) ;
245+ setSelectedElement ( ( prev ) => ( {
246+ ...prev ,
247+ element : type ,
248+ id : id ,
249+ open : false ,
237250 } ) ) ;
238251 }
239252
@@ -249,12 +262,6 @@ export default function Canvas() {
249262 } ) ) ,
250263 } ) ) ;
251264 }
252- setSelectedElement ( ( prev ) => ( {
253- ...prev ,
254- element : type ,
255- id : id ,
256- open : false ,
257- } ) ) ;
258265 } ;
259266
260267 /**
@@ -403,8 +410,6 @@ export default function Canvas() {
403410 * @param {PointerEvent } e
404411 */
405412 const handlePointerDown = ( e ) => {
406- if ( selectedElement . open && ! layout . sidebar ) return ;
407-
408413 if ( ! e . isPrimary ) return ;
409414
410415 // don't pan if the sidesheet for editing a table is open
0 commit comments