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

The undo stack inserts deleted content in the wrong flow nodes #712

Closed
christian-konrad opened this issue Jun 28, 2022 · 12 comments
Closed
Labels
bug Something isn't working spring cleaning Could be cleaned up one day

Comments

@christian-konrad
Copy link
Contributor

Describe the Bug

When you delete a name or id of a flow node in the properties panel, then add a new node and hit undo, the name or id is inserted back again - in the right property, but of the wrong flow node. So, the revert operation is not conducted properly. Also, adding the flow node itself is not reverted. It seems like the undo stacks of the properties panel and bpmn-js clash.

Steps to Reproduce

  1. Have a flow node
  2. Enter a name or id
  3. Remove the name or id (select all + entf/backspace/cut)
  4. Add a new flow node
  5. Hit undo
  6. -> The name or id is inserted back again, but in the currently selected flow node (the new one)

Or just see the videos.

Bildschirmaufnahme.2022-06-28.um.22.01.23.mov
Bildschirmaufnahme.2022-06-28.um.21.59.22.mov

(Not validated if this also applies to other properties than ids and names).

Expected Behavior

Hitting undo, at first the newly added flow node should be removed, then the name or id should be inserted back again in the original node.

Environment

  • Desktop Modeler 5.0.0 and Web Modeler (Nightly and our current dev env ultrawombat)
@christian-konrad christian-konrad added the bug Something isn't working label Jun 28, 2022
@barmac barmac added the ready Ready to be worked on label Jul 6, 2022 — with bpmn-io-tasks
@pinussilvestrus
Copy link
Contributor

Seems like this is related to direct editing visible after creating/appending tasks and text annotations.

Kapture 2022-07-19 at 13 49 54

I can't reproduce it if I append a flow node that's not immediately activating direct editing.

Kapture 2022-07-19 at 13 51 19

pinussilvestrus pushed a commit that referenced this issue Jul 19, 2022
@bpmn-io-tasks bpmn-io-tasks bot added in progress Currently worked on and removed ready Ready to be worked on labels Jul 19, 2022
pinussilvestrus pushed a commit that referenced this issue Jul 19, 2022
pinussilvestrus pushed a commit that referenced this issue Jul 19, 2022
@pinussilvestrus
Copy link
Contributor

pinussilvestrus commented Jul 19, 2022

I looked through the commit history to find a point where it is working properly. The bug even occurs in version 1.0.0-alpha.0.

I was not able to find the root cause for this in a time-boxed manner. However, I created a test case via 0dcd373 that tries to reproduce the issue.

Branch: 712-wrong-command-removal

What I found while creating the test case:

  • The test case is failing randomly because the name input sometimes has focus. It shouldn't be like that after append, as direct editing is activated. Sometimes it just works as expected.
  • When doing the same by firing command via commandStack only, everything works as expected.

This could be an indication that something is going on with handling the keyboard bindings + focusing properly between the modeler and properties panel.

I'd need more time to investigate this, so I'd propose to move this to the backlog as it's not a blocker.

/cc @christian-konrad @CatalinaMoisuc

@pinussilvestrus pinussilvestrus added the spring cleaning Could be cleaned up one day label Jul 19, 2022
@pinussilvestrus pinussilvestrus removed their assignment Jul 19, 2022
@pinussilvestrus pinussilvestrus added backlog Queued in backlog and removed in progress Currently worked on labels Jul 19, 2022
@marstamm
Copy link
Contributor

Expected Behavior

Hitting undo, at first the newly added flow node should be removed, then the name or id should be inserted back again in the original node.

As we are in the context of direct editing, undo should not be handled by bpmn-js at all but perform the native undo/redo on the contenteditable div

@nikku
Copy link
Member

nikku commented Aug 17, 2022

Could this be another one to be fixed by bpmn-io/diagram-js#662?

@marstamm
Copy link
Contributor

I will try it out with your branch (#739), but I am not confident that it will be solved. No actual undo is triggered currently. I suspect it has more to do with focus handling/Event listeners during re-render of the property panel

@marstamm
Copy link
Contributor

I can still reproduce it on #739

@nikku
Copy link
Member

nikku commented Aug 17, 2022

You'd need to test it against an end-to-end setup scenario: bpmn-io/diagram-js#662 (comment). There are just too many moving parts at the moment 😄

@marstamm
Copy link
Contributor

marstamm commented Aug 17, 2022

I did locally link the diagram and bpmn-js branches as well 😄
It is releavant that we have the Properties panel, I found the root cause and I believe it is not something we can handle in bpmn-js.

Root Cause

  • When you have 2 inputs and use the browser-native undo, it will switch the focused element.
    Recording 2022-08-17 at 11 04 59
  • Usually, we capture the keyDown events and handle undo/redo ourselves
  • DirectEditing does not have the custom key handlers, a historyUndo InputEvent is created. This is a normal input event and is not captured by keyHandlers
  • We reuse the input field for names and only change the value. This causes focus to be set and the value to be changed by the input event

Possible Solutions
Still thinking about these ones. As the expected behaviour would be to stay in direct editing, I think we should prevent the browser default there.

@marstamm
Copy link
Contributor

Same case can be created with undo via context pad, so the fix needs to be in the properties panel.
Recording 2022-08-17 at 13 20 35

I'll see if we can capture undoHistory events in the root before they reach the target and execute a commandstack undo instead

@nikku
Copy link
Member

nikku commented Aug 17, 2022

Given your analysis I believe we should simply make sure that input (task A) is different from input (task B) (via a key attribute).

If we do that though we'll run into the issue that we don't properly remember (and restore) collapse + expand states.

@marstamm
Copy link
Contributor

I was trying to use the beforeinput event to trigger commandstack undo when attempting to undo, but the beforeinput event is triggered on the direct editing container, the following input event in the properties panel.

Given your analysis I believe we should simply make sure that input (task A) is different from input (task B) (via a key attribute).

That makes sense. I'll try it out.
I have not looked at the collapse/expand states yet. From my understanding, if we only replace the inputs, the group should stay the same and could keep the collapse/expand state.

@nikku
Copy link
Member

nikku commented Aug 17, 2022

From my understanding, if we only replace the inputs, the group should stay the same and could keep the collapse/expand state.

Yes, however it will have other unwanted side-effects. I.e. caching of state fetched for Task A and making it available for Task B (use-case: custom stateful form elements).

I'm fine though to address / investigate this some day in the future.

marstamm added a commit to bpmn-io/properties-panel that referenced this issue Aug 17, 2022
marstamm added a commit to bpmn-io/properties-panel that referenced this issue Aug 17, 2022
philippfromme pushed a commit to bpmn-io/properties-panel that referenced this issue Aug 18, 2022
@marstamm marstamm added fixed upstream Requires integration of upstream change and removed backlog Queued in backlog labels Aug 19, 2022
marstamm added a commit that referenced this issue Aug 19, 2022
@fake-join fake-join bot closed this as completed in e07c420 Aug 19, 2022
@bpmn-io-tasks bpmn-io-tasks bot removed the fixed upstream Requires integration of upstream change label Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working spring cleaning Could be cleaned up one day
Development

No branches or pull requests

5 participants