Unexpected behavior of Delete/Backspace on inline text editing after upgrade to v6.1.1

Hello,

I would like to report a potential issue that I encountered after upgrading dhtmlxDiagram from v6.0.11 to v6.1.1.

Summary

After the upgrade, the behavior of the Delete / Backspace keys during inline text editing (e.g., lineTitle) has changed unexpectedly.

Steps to reproduce

  1. Use dhtmlxDiagram v6.1.1
  2. Double-click a lineTitle (or similar editable element) to enter text edit mode
  3. Place the cursor inside the text
  4. Press Delete or Backspace

Actual behavior

  • The entire diagram item (e.g., the line or shape) is removed

Expected behavior

  • Only the text content (item.text) should be modified/deleted
  • This was the behavior in v6.0.11

Additional context

It seems this behavior is related to the hotkey changes introduced in v6.1.1:

Workaround

I implemented a workaround by overriding the hotkeys and checking whether the text editor is active before removing the item:
https://snippet.dhtmlx.com/tqj53q3z

const editor = new dhx.DiagramEditor(document.body, {
    type: "default",
    hotkeys: {
        'delete': () => checkRemoveItem(),
        'backspace': () => checkRemoveItem(),
    }
});

const checkRemoveItem = () => {
    const target = ["lineTitle", "circle"];
    const selected = editor.diagram.selection.getItem();

    if (selected !== undefined) {
        if (target.includes(selected.type)) {
            const element = document.querySelector(
                `[dhx_editor_id="${selected.id}_editor"]`
            );
            if (element && element.contains(document.activeElement)) {
                // editing text → do nothing
            } else {
                editor.diagram.data.remove(selected.id);
            }
        } else {
            editor.diagram.data.remove(selected.id);
        }
    }
};

Question

  • Is this change in behavior intentional?
  • If so, is there an official way to distinguish between “text editing mode” and “item selection mode” when handling hotkeys?

Thank you for your support.

Hello @kanta,

Thank you for the detailed description of the issue and provided workaround.
It’s not an intentional change, and the dev team already works on a fix, I will notify you on any updates.

Warm regards,

1 Like

Hello @kanta,

The dev team already fixed the issue with edit mode in the latest release:

You can test it in the following demo:

Warm regards.,

@Siarhei
Hello,

Thank you for fixing the Backspace key behavior in the latest release.

While reviewing the hotkey behavior, I noticed the following regarding the Delete key.

After verification, I found that the behavior is the same in both v6.0.11 and v6.1.2.

Specifically, when editing text (e.g., lineTitle) and the cursor is active inside the text field, pressing the Delete key is handled as a hotkey and removes the entire item, instead of modifying the text.

Since this behavior is consistent across versions, it seems this may be the intended design.

Could you please clarify whether handlizng the Delete key as a hotkey even during text editing is expected behavior?

Thank you for your support.

Best regards,
kanta