When adding commands via the Commander Ribbon Tab, or when changing icon, color, name, or mode, the elements get reordered. This requires the user to re-reorder the ribbon elements everytime a new command is added or an already existing one is changed.
Relevant errors (if available)
No response
Steps to reproduce
Open the Commander Ribbon Tab
Add or modify (icon, color, name, mode) a command
Observe that the elements are reordered
Expected Behavior
Changes should be applied without reordering the existing elements. Adding a new command should not trigger an additional reorder operation.
Additional context
Proposed fix:
Implement a new update() method in leftRibbonManager.ts that only adds commands without removing them
Modify the handleRename method in commandViewerComponent.tsx to:
a. First remove the command using the manager.removeCommand() method
b. Then make the name change
c. Finally, add the command again using the manager.addCommand() method
Replace manager.reorder() calls with manager.update() for the following functions in src/ui/components/commandViewerComponent.tsx:
handleNewIcon
handleModeChange
handleColorChange
Modify addCommand() and removeCommand() method to use the id for finding the native action.
Use nativeAction.hidden property to handle mode changes without reordering
Remove the reorder() call in "Add command" button click handler
Attachments:
The following attachments contain the fix which allows adding, renaming, and removing commands via the Commander Ribbon tab, or changing icon, color, name, or mode, without the need to reorder all items:
Limitations:
The Plugin.addRibbonIcon(icon, title) method only permits specifying a name and icon, without an option for specifying a unique identifier. Consequently, changing a name currently causes this element to reorder in ribbon and the Commander Ribbon tab.
Additional notes:
In the current implementation, removing and immediately re-adding the element with a new name results in reordering that command in the ribbon and in the Command Ribbon tab. Another approach would be to assign elements a UID and set the title field of the newly created ribbon item immediately afterward, allowing a name change without reordering. However, this would require changes to the interface and initialization process of the CommandIconPair, affecting multiple files (all instances of CommandIconPair would need to include the UID).
While implementing this field requires changing the initialization process in other parts of the program, as long as this is correctly implemented, it would not impact any of the functionality of the program. In fact, it would be possible to use the UID only on special occasions (e.g., ribbon) where desired.
Describe the bug
When adding commands via the Commander Ribbon Tab, or when changing icon, color, name, or mode, the elements get reordered. This requires the user to re-reorder the ribbon elements everytime a new command is added or an already existing one is changed.
Relevant errors (if available)
No response
Steps to reproduce
Expected Behavior
Changes should be applied without reordering the existing elements. Adding a new command should not trigger an additional reorder operation.
Additional context
Proposed fix:
update()
method inleftRibbonManager.ts
that only adds commands without removing themhandleRename
method incommandViewerComponent.tsx
to: a. First remove the command using themanager.removeCommand()
method b. Then make the name change c. Finally, add the command again using themanager.addCommand()
methodmanager.reorder()
calls withmanager.update()
for the following functions insrc/ui/components/commandViewerComponent.tsx
:addCommand()
andremoveCommand()
method to use the id for finding the native action.nativeAction.hidden
property to handle mode changes without reorderingreorder()
call in "Add command" button click handlerAttachments: The following attachments contain the fix which allows adding, renaming, and removing commands via the Commander Ribbon tab, or changing icon, color, name, or mode, without the need to reorder all items:
Limitations: The
Plugin.addRibbonIcon(icon, title)
method only permits specifying a name and icon, without an option for specifying a unique identifier. Consequently, changing a name currently causes this element to reorder in ribbon and the Commander Ribbon tab.Additional notes: In the current implementation, removing and immediately re-adding the element with a new name results in reordering that command in the ribbon and in the Command Ribbon tab. Another approach would be to assign elements a UID and set the title field of the newly created ribbon item immediately afterward, allowing a name change without reordering. However, this would require changes to the interface and initialization process of the CommandIconPair, affecting multiple files (all instances of CommandIconPair would need to include the UID).
While implementing this field requires changing the initialization process in other parts of the program, as long as this is correctly implemented, it would not impact any of the functionality of the program. In fact, it would be possible to use the UID only on special occasions (e.g., ribbon) where desired.
Operating system
Linux