Hi everyone,
I'm implementing a feature where custom commands are added to the TopPaneMenu (the three dots menu) when an object is selected in the view.
This works fine — commands are shown based on the selected object.
However, I want the three dots menu icon to disappear when the user clicks on empty space (i.e., no object is selected).
Right now, I listen to the SelectionChanged
event, and when no objects are selected, I call a clearCustomCommands
function:
async function clearCustomCommands(shellFrame) {
for (const commandId of commandMap.keys()) {
try {
await shellFrame.Commands.RemoveCustomCommandFromMenu(commandId, MFiles.MenuLocation.MenuLocation_TopPaneMenu);
await shellFrame.Commands.RemoveCustomCommandFromMenu(commandId, MFiles.MenuLocation.MenuLocation_ContextMenu_Bottom);
} catch (err) {
console.error(`Failed to remove commandId ${commandId}:`, err);
}
}
commandMap.clear();
}
The problem is: the three dots icon still remains visible until the user manually clicks it — only then it refreshes and disappears.
It seems like the UI doesn’t re-render automatically when the last command is removed.
Do you have any suggestions on how to solve this?