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

Multi-selection in viewer causes black boxes #2135

Closed
nikku opened this issue Apr 10, 2024 · 21 comments · Fixed by #2253
Closed

Multi-selection in viewer causes black boxes #2135

nikku opened this issue Apr 10, 2024 · 21 comments · Fixed by #2253
Assignees
Labels
bug Something isn't working embedding good first issue Good for newcomers spring cleaning Could be cleaned up one day

Comments

@nikku
Copy link
Member

nikku commented Apr 10, 2024

Describe the Bug

As a user I'm embedding the viewer as recommended in the starter project. When I select elements no outline is shown, I can still react to selected events; this I expect.

However when I select more than one element a black box appears that hides the diagram:

capture vSxTJn_optimized

Steps to Reproduce

  1. open starter viewer example
  2. select more than one element using SHIFT + click
  3. see black box appear

Expected Behavior

  • No black box appears
  • (Alternative) Selection is not available for the viewer

Environment

  • Browser: Chrome 110
  • OS: Linux
  • Library version: v14.0.0
@nikku nikku added bug Something isn't working embedding labels Apr 10, 2024
@nikku nikku mentioned this issue Apr 10, 2024
@philippfromme
Copy link
Contributor

philippfromme commented Apr 10, 2024

I think that we need to be clear on what a viewer is. The default viewer in my opinion, should behave like viewing an SVG. No interactivity at all. I never liked the fact that you get selection behavior in the viewer. Now, there are use cases that need an interactive viewer. In these cases, users need to include the required features and stylesheets as well. Alternatively, we could offer something similar to the navigated viewer.

@philippfromme
Copy link
Contributor

There would still remain the problem of interactive viewer and no selection outlines for connections. In the modeler selection is indicated by showing the bendpoints.

image

In an interactive viewer selecting connections should be indicated. We should have a solution for that.

@nikku
Copy link
Member Author

nikku commented Apr 10, 2024

No interactivity means that you cannot properly react to states in i.e. overlays. Hence the viewer would always offer basic interactivity, including hover and selection.

@philippfromme
Copy link
Contributor

Overlays is a feature of an interactive viewer, I'd say.

@barmac
Copy link
Member

barmac commented Apr 10, 2024

I'd say there are 4 ways to display diagram:

  • Modeler
  • NavigatedViewer
  • Viewer with some interactivity
  • Displaying result of Viewer.saveSVG

Otherwise we should rename the Viewer to Renderer, as that's what it is without any interactivity.

@nikku
Copy link
Member Author

nikku commented Apr 10, 2024

Thanks for #2135 (comment) @barmac. I subscribe to it. Without interactivity the viewer is simply a renderer.

You can roll your own barebones renderer if you so desire on top of the BaseViewer package.

@nikku nikku added good first issue Good for newcomers spring cleaning Could be cleaned up one day labels Apr 15, 2024
@nikku nikku added the backlog Queued in backlog label Apr 16, 2024 — with bpmn-io-tasks
@misiekhardcore misiekhardcore self-assigned this Oct 29, 2024
@misiekhardcore misiekhardcore added in progress Currently worked on and removed backlog Queued in backlog labels Oct 29, 2024
@misiekhardcore
Copy link
Contributor

misiekhardcore commented Oct 29, 2024

In the modeler starter example it works fine, it does not work locally in viewer starter example with same issue as in the linked example. I can see that the issue occurs cause there are no diagram-js styles added.
The issue here is in general indicating anything being selected, even a single element - is this expected that we don't want to outline a single selection in Viewer?

@philippfromme
Copy link
Contributor

The selection and outline features are part of the both the viewer and the modeler. Unless we decide to remove it from the viewer I'd say you simply must include diagram-js.css for it to work properly.

But even then there are a couple of issues:

  • connection outline not shown (we decided to not show connection outlines anymore since the bendpoints feature indicates selection, we could enable it in the viewer)
  • selecting multiple elements always selects text (at least in the example)

@misiekhardcore
Copy link
Contributor

misiekhardcore commented Oct 29, 2024

After adding the missing diagram-js.css the selection visuals seem to be fixed, the issue with selecting text persists but maybe it should be handled in a separate issue?

Screencast.from.2024-10-29.15-43-07.webm

@philippfromme
Copy link
Contributor

philippfromme commented Oct 29, 2024

After discussing this with @nikku our proposal is:

As a result you can use the viewer without any additional CSS file, the selection feature works but no outline will be shown by default, you can add it by adding the outline feature or applying custom CSS using the .djs-element.selected selector.

@misiekhardcore
Copy link
Contributor

misiekhardcore commented Oct 29, 2024

Won't this require the Outline feature to now be aware of selection and canvas? Or I misunderstand what's need to be done?

@nikku
Copy link
Member Author

nikku commented Oct 30, 2024

@misiekhardcore The purpose of the outline feature is to render an outline (around elements), to be styled based on selection and other state. It is an optional feature in the toolbox.

Selection on the other hand is a more core feature of the toolbox, and hence we want to keep it as minimal as possible. The way components plug into selection is through events, so we already loosely couple things (nothing breaks if selection ends up not being there, but it is, if you want to make anything selectable):

function MyComponent(eventBus) {
  
  eventBus.on('selection.changed', function({ newSelection, oldSelection }) {
    ...
  });
}

We could consider to not move the SelectionOutline into the outline feature, but make it a dedicated concern (standalone feature), as previously sketched here. However, for me it conceptional fits into the "outline" bucket.

What I propose is to add a MultiSelectionOutline component within the outline feature, rendering the (multi-selection) outline.


What is also useful in terms of design is to clearly separate UI and non-UI components. As part of bpmn-js-headless we investigated a way to make core bpmn-js available for headless use. This works as long as only non-UI components ("the business logic") is used, but breaks if components wildly mix UI and non-UI concerns. In this particular case, using the actual selection (to do whatever, i.e. trigger an editor action afterwards) will blow up the headless tool, unless explicitly detangled. Another reason to make this change.

I don't necessarily agree with bpmn-io/diagram-js@5db35ec, "just moving the selection visuals out", as this will also make the markers unavailable. Hence I propose moving the outline (the only UI aspect) to an actual UI component, the outline feature.

@misiekhardcore
Copy link
Contributor

Okay, that brings some more light into the problem we want to fix. I personally like the idea of having a separate MultiSelectOutline feature to have a better granularity and allowing the user to decide what they need

@misiekhardcore
Copy link
Contributor

So, I opened a PR, but should I open an issue in diagram-js? or opening a PR and relating it to this one is the correct way?
Also I do not really know how to test it out, how can I play with the changes I made?

@nikku
Copy link
Member Author

nikku commented Oct 30, 2024

You can link the PR in your comment, to establish the context. No other issue is needed, if the PR is self explainatory in what we want to accomplish, and why. It should provide a clear rationale, along the lines of this.

@misiekhardcore
Copy link
Contributor

misiekhardcore commented Oct 30, 2024

I have decided to create a separate issue for moving multi-select outlines to a separate module as this won't fix the issue described here.
The core problem here is that svg rect gets the black fill by default and as long as we include the diagram-js css file, it works fine, because it has styles defined for the multi-select which are setting fill: none (here).
bpmn-js has no default styling for this

How should we handle this case? Should these styles be added to bpmn-js css file?
Technically if user does not pull in the Outline feature, it will all work now, and if they did add the Outline feature, they should include the diagram-js styles right?

@nikku
Copy link
Member Author

nikku commented Oct 30, 2024

Technically if user does not pull in the Outline feature, it will all work now, and if they did add the Outline feature, they should include the diagram-js styles right?

That is the resolution, and we'll ship the viewer without the outline. As a result the viewer will not depend on the external style sheet, which always has been our intention. Or do I miss anything?

If I understood correctly, then #2253 and bpmn-io/diagram-js#943 solve this issue, which was our intention.

@misiekhardcore
Copy link
Contributor

If I understood correctly, then #2253 and bpmn-io/diagram-js#943 solve this issue, which was our intention.

Yes, exactly

@nikku nikku added the fixed upstream Requires integration of upstream change label Oct 31, 2024 — with bpmn-io-tasks
@nikku nikku removed the in progress Currently worked on label Oct 31, 2024
@nikku
Copy link
Member Author

nikku commented Oct 31, 2024

Ok, moved this issue to fixed upstream. Let's close it once the linked PRs / issues are merged.

@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed fixed upstream Requires integration of upstream change labels Nov 4, 2024
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Nov 4, 2024
nikku added a commit that referenced this issue Nov 5, 2024
Turns out our custom outlines got missing with 583195a,
time to restore them (for modeling).

Related to #2135
nikku added a commit that referenced this issue Nov 5, 2024
Turns out our custom outlines got missing with 583195a,
time to restore them (for modeling).

Related to #2135
barmac pushed a commit that referenced this issue Nov 6, 2024
Turns out our custom outlines got missing with 583195a,
time to restore them (for modeling).

Related to #2135
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 `[email protected]`

## 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 `[email protected]`
* `DEPS`: update to `[email protected]`

### 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 `[email protected]`

## 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 `[email protected]`

## 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
bug Something isn't working embedding good first issue Good for newcomers spring cleaning Could be cleaned up one day
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants