docs: Update custom drag handle menu example #1628
Merged
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.
The example for customizing drag handle menu items creates a new component for the custom drag handle menu inline in the
dragHandleMenu
prop in theSideMenu
component. Because the component is basically recreated on each re-render, the drag handle menu itself gets unnecessarily re-rendered a lot, and this can lead to some issues. Namely the colors dropdown gets hidden while scrolling in the Mantine UI, while the drag handle menu doesn't open at all in the ShadCN UI.This PR updates the example so that the drag handle component is now defined externally instead of inline, which fixes the re-rendering issues. Tbh I would consider refactoring all of the examples in this way as this is good practice for React, but there's a small trade-off in simplicity that we would be making. However, other UI elements don't have noticeable rendering issues because of this, unlike the drag handle menu.
Closes #1602