fix: make 'movable' style attribute behave as expected (#248)

The 'movable' style attribute of cells had the opposite effect as what
would be expected. When set to false, cells could be moved, and when true,
cells couldn't be moved.
This is something that got lost in translation in the conversion from mxGraph.
Previously, it assumed that if 'movable' had any value, it must be the string "0". This
attribute got changed to a boolean in Typescript, but it looks like the
check never got updated leading to this strange behaviour.

The fix is fairly simple.
If 'movable' is undefined, then we assume that it's true.
If not, then we check it like a regular boolean.
development
Eric Redekopp 2023-10-12 02:23:32 -06:00 committed by GitHub
parent 54c82230c1
commit f09abdf53a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -2712,15 +2712,17 @@ export const CellsMixin: PartialType = {
},
/**
* Returns true if the given cell is moveable. This returns {@link cellsMovable}
* for all given cells if {@link isCellLocked} does not return true for the given
* cell and its style does not specify {@link 'movable'} to be 0.
* Returns `true` if the given cell is movable. This returns {@link cellsMovable}
* for all given cells if {@link isCellLocked} does not return `true` for the given
* cell, and its style does not specify {@link CellStateStyle.movable} to be `false`.
*
* @param cell {@link mxCell} whose movable state should be returned.
*/
isCellMovable(cell) {
const style = this.getCurrentCellStyle(cell);
return this.isCellsMovable() && !this.isCellLocked(cell) && !style.movable;
return this.isCellsMovable()
&& !this.isCellLocked(cell)
&& (style.movable ?? true);
},
/**