-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue with moving elements beyond border #2244
base: develop
Are you sure you want to change the base?
Fix issue with moving elements beyond border #2244
Conversation
…ntion of moving beyond border
Hi, Thank you for your PR. Can you please make sure the contribution meets the requirements in CONTRIBUTING? |
…ndefined to prevent element from moving beyond border
…github.com/Adam-Thometz/bpmn-js into 2210-prevent-moving-elements-beyond-border
Thank you for the feedback @barmac I updated the commit message and added a test to |
Thanks, I will have a look at this again today. |
modules: testModules | ||
})); | ||
|
||
it('should limit movement when attempting to drag outside the viewport', inject(function(elementRegistry, move, dragging, canvas) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted the change to the rules, and the test still passes. What we'd like to achieve is that the test is failing without the change you introduced: https://github.com/bpmn-io/bpmn-js/pull/2244/files#diff-6031dc6e8e3d4e38aef3c1dda35e6ff836a6b6be1263157300284d0191a6d5d4R931
Otherwise, the test does not verify the fix as it is passing without any changes to the library code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to view some documentation on how the inject function works? Trying to figure out how to simulate the viewport bc in the test it does move outside but it isn't perceived as a viewport so it doesn't snap back if that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Adam-Thometz inject will execute the test within a previously bootstrapped bpmn-js instance, and allows you to access internal services.
Similar to this:
const bpmnJS = new BpmnModeler();
const testFn = function(eventBus) { ... };
bpmnJS.invoke(testFn);
@Adam-Thometz are you still working on it? |
See original issue for context
Proposed Changes
Change one line of code in
lib/features/rules/BpmnRules.js
in thecanMove
function:Reasoning
If a user starts dragging an element, the target is undefined. If a user drags an element outside the canvas, the target is null. Since both cases are considered nullish, they will both return true (meaning the user can drop the element). We want the latter case to return false.
Steps to reproduce
a. If dragged within, should be successful
b. If dragged outside the element but within the canvas, should fail
c. If dragged outside the element AND outside the canvas, should fail