Hi,
I think I might have found a bug related to task selection when using the taskMenu with multiple selected tasks.
Behavior observed
Select multiple tasks.
Right-click on one of the selected tasks (inside the task bar rectangle) to open the taskMenu.
Click on a custom menu item that opens a confirmation modal.
After confirming the modal, the selection changes:
Only the task that was right-clicked remains selected, while all the other previously selected tasks are deselected.
Expected behavior
The original multi-selection should remain intact after confirming the modal, since the user intentionally selected multiple tasks before opening the menu.
Important detail
If I right-click on the left grid or on the empty space of the Gantt row (not on the task bar), the selection does not change after confirmation.
The issue happens only when the right-click occurs directly on the task bar element.
Reproduction
I reproduced the issue in this demo (link), adding the code below to register a custom taskMenu item and show a confirmation modal.
JS
let selectedRecords = [];
gantt.features.taskMenu.items['customItem'] = {
text: 'Custom item',
icon: 'b-icon-cog',
weight: 10,
onItem: ({ taskRecord }) => {
console.warn('Custom item clicked:', selectedRecords);
showConfirmDialog();
},
}
gantt.listeners = {
selectionChange: ({ selection }) => {
selectedRecords = selection;
console.log('selectionChange', selection);
}
};
function showConfirmDialog() {
const dialogMask = document.createElement('div');
dialogMask.className = 'dialog-mask';
const dialog = document.createElement('div');
dialog.className = 'dialog';
dialogMask.appendChild(dialog);
const title = document.createElement('span');
title.innerText = 'Are you sure?';
dialog.appendChild(title);
const okButton = document.createElement('button');
okButton.innerText = 'Ok';
okButton.onclick = () => {
console.log('Dialog ok', selectedRecords);
dialogMask.remove();
}
dialog.appendChild(okButton);
document.getElementById('container').appendChild(dialogMask);
}CSS
.dialog-mask {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #00000066;
z-index: 9999;
}
.dialog {
position: absolute;
top: 50%;
left: 50%;
background: white;
padding: 10px;
transform: translate(-50%, -50%);
}Question
Is this expected behavior?
Thanks!