Skip to content
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

Elements Within Sub-Processes are Placed Horizontally #2127

Closed
sombrek opened this issue Apr 5, 2024 · 5 comments · Fixed by #2205
Closed

Elements Within Sub-Processes are Placed Horizontally #2127

sombrek opened this issue Apr 5, 2024 · 5 comments · Fixed by #2205
Assignees
Labels
enhancement New feature or request pr welcome We rely on a community contribution to improve this.

Comments

@sombrek
Copy link
Contributor

sombrek commented Apr 5, 2024

Describe the Bug

Elements are always placed horizontally within collapsed sub processes, even when the sub-process activity is placed within a vertical pool.

Steps to Reproduce

  1. Create a vertical pool.
  2. Add a collapsed sub-process.
  3. Navigate into the sub-process.
  4. Append elements.

Expected Behavior

The new elements should be placed vertically.

Environment

  • Library version: 17.2.0

Additional Information

I think ModelingUtil needs to be extended. I found DrilldownUtil and I see it used with ElementRegistry, but I'm not sure if (and how) ElementRegistry can be used within ModelingUtil.

@barmac Thank you for your great support so far. Do you have an idea how to handle this case?

@sombrek sombrek added the bug Something isn't working label Apr 5, 2024
@sombrek sombrek changed the title Elements Within Sub-Processes are Places Horizontally Elements Within Sub-Processes are Placed Horizontally Apr 6, 2024
@barmac
Copy link
Member

barmac commented Apr 8, 2024

The method that you linked relies on the diagram parent. As a collapsed subprocess is the root of the diagram, it does not have a parent, and thus no participant/pool parent is detected.

We could handle this by checking the businessObject.$parent property instead. This should make it possible to traverse the semantic model instead of the diagram.

@barmac barmac added pr welcome We rely on a community contribution to improve this. backlog Queued in backlog labels Apr 8, 2024
@sombrek
Copy link
Contributor Author

sombrek commented Apr 13, 2024

Good idea. The Participant can be found that way. However, the diagram element is needed to get the isHorizontal attribute.
Using getDi causes an error that refers to #1472.

I'm not sure if it's possible to get the (correct) diagram for the Participant. What would be the best way to get the diagram element?

@barmac barmac added enhancement New feature or request and removed bug Something isn't working labels Apr 15, 2024
@barmac
Copy link
Member

barmac commented Apr 15, 2024

Thanks for trying out the suggestion. Indeed it is a bit more tricky than I assumed.

The getDi error is correct, and it is due to the nature of BPMN Diagram Interchange. BPMN allows to have multiple diagrams within the file, and those diagrams can even depict the same elements but with different coordinates, sizes, and attributes like expansion or vertical/horizontal.

So the relationship between a semantic element and a DI element is not one-to-one, but rather one-to-many (where many is usually one though). The consequence of that is that for a given semantic element, we can retrieve the DI element only within the context of the currently displayed diagram, and in a collapsed subprocess view the participant has no DI, thus the function errors.

I prepared a codesandbox which shows the DI flexibility in bpmn-js. The top-bar buttons allow you to switch between the diagrams of which the first two depict exactly the same semantic elements, but in the first one the participant is depicted as vertical, but on the other it's a horizontal pool.

Bottom-line is that we cannot always tell for sure if the subprocess is currently rendered in a vertical or a horizontal participant.

However, we could potentially employ some heuristics to make most cases working. I believe BPMNs like in the linked example are unusual. I'd rather expect to have a single participant depiction per file. We could then expect the first depicted parent to determine whether the subprocess is vertical or horizontal.

For the implementation, I'd suggest to take the inspiration from the Drilldown Breadcrumbs feature which handles the subprocess-to-parent navigation. Cf. https://github.com/bpmn-io/bpmn-js/blob/develop/lib/features/drilldown/DrilldownBreadcrumbs.js#L68

@barmac
Copy link
Member

barmac commented Apr 15, 2024

For the sake of completeness, I added a third diagram Vertical-expanded which depicts the same model but the subprocess is expanded now. Notice however that in this case the drilldown feature breaks as the contained elements are not displayed.

@bpmn-io-tasks bpmn-io-tasks bot removed the backlog Queued in backlog label Jul 20, 2024
@barmac barmac self-assigned this Jul 30, 2024
@barmac barmac added the needs review Review pending label Jul 30, 2024
@barmac barmac closed this as completed in 61f0d72 Aug 19, 2024
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Aug 19, 2024
nikku pushed a commit that referenced this issue Sep 9, 2024
@nikku
Copy link
Member

nikku commented Sep 23, 2024

This can be tested using a vertical modeling diagram.

ElRaptorus added a commit to 5minds/bpmn-js that referenced this issue Feb 4, 2025
# Changes 

Siehe Changelog:
https://github.com/bpmn-io/bpmn-js/blob/develop/CHANGELOG.md

## 18.1.2

* `FIX`: canvas `autoFocus` must explicitly be enabled
([bpmn-io/diagram-js#956](bpmn-io/diagram-js#956))
* `FIX`: properly integrate `zoomscroll` with canvas focus
([bpmn-io/diagram-js#956](bpmn-io/diagram-js#956))
* `FIX`: properly integrate `movecanvas` with canvas focus
([bpmn-io/diagram-js#956](bpmn-io/diagram-js#956))

## 18.1.1

* `FIX`: adjust search to prioritize start of word and exact matches
([bpmn-io/diagram-js#953](bpmn-io/diagram-js#953))
* `FIX`: ignore whitespace when searching
([bpmn-io/diagram-js#954](bpmn-io/diagram-js#954))

## 18.1.0

* `FIX`: clear selection when opening search pad
([bpmn-io/diagram-js#947](bpmn-io/diagram-js#947))
* `FIX`: correct dangling selection after search pad interaction
([bpmn-io/diagram-js#947](bpmn-io/diagram-js#947))
* `DEPS`: update to `diagram-js@15.2.2`

## 18.0.0

* `FEAT`: remove `outline` from `Viewer` modules
([bpmn-io#2135](bpmn-io#2135))
* `FEAT`: make `Canvas` a focusable element
([bpmn-io/diagram-js#662](bpmn-io/diagram-js#662))
* `FEAT`: implicit keyboard binding
([bpmn-io/diagram-js#662](bpmn-io/diagram-js#662))
* `FEAT`: integrate with global `search`
([bpmn-io#2235](bpmn-io#2235))
* `FEAT`: integrate `popup-menu` with `search`
([bpmn-io/diagram-js#932](bpmn-io/diagram-js#932))
* `FEAT`: recognize modern `search` tokens in `search-pad`
([bpmn-io/diagram-js#932](bpmn-io/diagram-js#932))
* `FIX`: correctly handle duplicate entries and whitespace in `search`
([bpmn-io/diagram-js#932](bpmn-io/diagram-js#932))
* `FIX`: find `search` terms across all keys
([bpmn-io/diagram-js#932](bpmn-io/diagram-js#932))
* `FIX`: `search` always returns tokens for matched items
([bpmn-io/diagram-js#932](bpmn-io/diagram-js#932))
* `FIX`: prevent crash during label adjustment
([bpmn-io#2239](bpmn-io#2239))
* `FIX`: keep existing loop characteristics when toggling through the
replace menu ([bpmn-io#2251](bpmn-io#2251))
* `FIX`: prevent covering multi selection with black box in `Viewer`
([bpmn-io#2135](bpmn-io#2135))
* `FIX`: generate types for main entry
([`986e2bb`](bpmn-io@986e2bb))
* `FIX`: correct handling of group name with whitespace only
([bpmn-io#2231](bpmn-io#2231))
* `DEPS`: update to `bpmn-moddle@9`
([bpmn-io#2114](bpmn-io#2114))
* `DEPS`: update to `diagram-js@15.1.0`
* `DEPS`: update to `diagram-js-direct-editing@3.2.0`

### Breaking Changes

* Require `Node >= 20`
* `Canvas` is now a focusable element and provides better support for
native browser behaviors. Focus can be controlled with new `focus` and
`restoreFocus` APIs
([bpmn-io/diagram-js#662](bpmn-io/diagram-js#662)).
* Keyboard is now implicitly bound to canvas SVG element. Calls to
`keyboard.bind` and `keyboard.bindTo` now result with a descriptive
console error and have no effect
([bpmn-io/diagram-js#662](bpmn-io/diagram-js#662)).

## 17.11.1

* `FIX`: handle searching elements without labels
([bpmn-io#2232](bpmn-io#2232),
[bpmn-io#2234](bpmn-io#2234))

## 17.11.0

* `FEAT`: align search styles with other popups
([bpmn-io#2187](bpmn-io#2187))
* `FEAT`: prioritize start of tokens in search results
([bpmn-io#2187](bpmn-io#2187))
* `FIX`: do not commit viewport changes on `ESC`
([bpmn-io#2189](bpmn-io#2189),
[bpmn-io#2187](bpmn-io#2187))
* `DEPS`: update to `diagram-js@14.10.0`

## 17.10.0

* `CHORE`: correct various type hints
([bpmn-io#2228](bpmn-io#2228))
* `FIX`: pasting compensation activity without boundary event
([bpmn-io#2070](bpmn-io#2070))
* `FIX`: lane resize constraints for se and nw direction
([bpmn-io#2209](bpmn-io#2209))
* `FIX`: auto place elements vertically in sub-processes
([bpmn-io#2127](bpmn-io#2127))
* `FIX`: hide lane label during direct editing
* `DEPS`: update to `diagram-js@14.9.0`

## 17.9.2

* `FIX`: keep direction when collapsing pools
([bpmn-io#2208](bpmn-io#2208))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pr welcome We rely on a community contribution to improve this.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants