Rotated rectangles won't snap to grid correctly
Preflight Checklist
- [x] I agree to follow the Code of Conduct that this project adheres to.
- [x] I have searched the issue tracker for a feature request that matches the one I want to file, without success.
You must agree to search and the code of conduct. You must fill in this entire template. If you delete part/all or miss parts out your issue will be closed.
If you are technical, you should report bugs along the lines of https://marker.io/blog/how-to-write-bug-report. If you are not technical, we will make allowances, please try to make an effort to understand the process.
Describe the bug I have somehow managed to create a diagram containing some rectangles that won't align correctly with the grid – they snap to an offset from the grid. Issue #4310, which couldn't be reproduced, may relate.
To Reproduce I have tried to reproduce the bug from scratch but could not. However, I have attached a cut down version of the diagram showing the problem instead.
Expected behavior When the grid is enabled, moving a rectangle causes it to snap precisely to the grid, even if it starting from a position that is not aligned with the grid.
Screenshots The green rectangle isn't aligned with the grid, and won't snap to it when moved:
draw.io version (In the Help->About menu of the draw.io editor):
- draw.io version v26.2.2, accessed at app.diagrams.net
Desktop (please complete the following information):
- OS: macOS Sequoia 15.3.2
- Browser: Chrome
- Browser Version: Version 134.0.6998.166 (Official Build) (arm64)
Smartphone (please complete the following information):
- N/A
I tested the problem in incognito/private mode with all browser extensions switched off, write "yes" below:
- yes
Additional context In the attached file, the rectangles originally contained text (I deleted it to remove some work-related info, although it wasn't confidential info), the blue ones were created first, then the first green one was created by copying a blue one, rotating it 90 degrees (causing the text within to rotate too), and then changing the colour. Later I noticed that the green ones weren't aligned to the grid correct, so moved them to snap them to the grid, but they will only snap to an offset from the grid.
Looking at the XML within the file, I notice that the green rectangles have a non-integer width, which is odd because the blue rectangles they were created from do not have a non-integer height. Maybe I adjusted the width accidentally. Obviously the non-integer width means that two corners of the rectangle cannot align with the grid, but none of the corners will align with the grid.