Fix: Commander Ribbon Elements Reordering on Changes #138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
When adding commands via the Commander Ribbon Tab, or when changing icon, color, name, or mode, the elements are getting reordered on the ribbon. This requires the user to re-reorder the ribbon elements every time a new command is added or an already existing one is changed.
This fix allows adding, renaming, and removing commands via the Commander Ribbon tab, or changing icon, color, name, or mode, without them being reordered on the ribbon.
Changes:
Implemented a new update() method in leftRibbonManager.ts that only adds commands without removing them
Modified the handleRename method in commandViewerComponent.tsx to handle rename with only the renamed command being reordered:
a. First, the command is being removed using the manager.removeCommand() method
b. Then the name of the command is being changed
c. Finally, the command is being added again using the manager.addCommand() method
Replaced manager.reorder() calls with new method manager.update() for the following functions in src/ui/components/commandViewerComponent.tsx to handle icon/mode/color change without reordering:
Modified addCommand() and removeCommand() method to use the id (instead of the name) for finding the native action.
Used nativeAction.hidden property to handle mode changes without reordering
Removed the reorder() call in "Add command" button click handler to handle adding commands without reordering.
Additional References: