-
Notifications
You must be signed in to change notification settings - Fork 228
feat(compass-components): add context menu COMPASS-9386 #6956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…p menu state consistent The refactor is meant to make the Leafygreen integration more straightforward: 1. We stick to item groups and instead have a single wrapper to handle any rendering differences between groups. This allows the wrapper to always have context of all items when rendering which is useful when inserting menu seperators in Leafygreen. Also encourages consistent UI (while allowing per-case customization if needed at wrapper-level). We could introduce itemWrappers instead of itemGroups but having one wrapper handling all seems cleaner to me. 2. More of the responsibility is moved to a parent wrapper component that will house the context menu. This allows us to standardize the right click menu and make better use of Leafygreen's menu component including its click handling (which has been removed from the context menu library). 3. Menu state (i.e. position) is now preserved even closed; this is useful for leafygreen's menu to animate in the same position instead of losing the position all together.
…ompass into gagik/context-menu-compass-ui
…p menu state consistent The refactor is meant to make the Leafygreen integration more straightforward: 1. We stick to item groups and instead have a single wrapper to handle any rendering differences between groups. This allows the wrapper to always have context of all items when rendering which is useful when inserting menu seperators in Leafygreen. Also encourages consistent UI (while allowing per-case customization if needed at wrapper-level). We could introduce itemWrappers instead of itemGroups but having one wrapper handling all seems cleaner to me. 2. More of the responsibility is moved to a parent wrapper component that will house the context menu. This allows us to standardize the right click menu and make better use of Leafygreen's menu component including its click handling (which has been removed from the context menu library). 3. Menu state (i.e. position) is now preserved even closed; this is useful for leafygreen's menu to animate in the same position instead of losing the position all together.
82a10c5
to
ca1fb86
Compare
…ompass into gagik/context-menu-compass-ui
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<ContextMenuProviderBase wrapper={ContextMenu}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe there's a better way to structure this, including the wrapper passing in general
30b97a5
to
6b6e398
Compare
7e90b5f
to
4dafa7b
Compare
This reverts commit 4dafa7b and uses testing-library instead.
let component: ReactWrapper; | ||
beforeEach(function () { | ||
component = mount( | ||
<DocumentListView | ||
docs={hadronDocs} | ||
isEditable={false} | ||
isTimeSeries={false} | ||
/>, | ||
{ wrappingComponent: ContextMenuProvider } | ||
); | ||
}); | ||
|
||
afterEach(function () { | ||
component?.unmount(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why this was needed and if it accidentally crept in from another PR? cc @gagik (tagging you for when you get back - it's not urgent)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing unintended side-effects (runtime errors) for other tests when running because it'd try to mount a component during the test discovery phase (basically mocha would import the file and it'd already run mount
)
import { useContextMenuItems, ContextMenu } from './context-menu'; | ||
import type { ContextMenuItem } from '@mongodb-js/compass-context-menu'; | ||
|
||
describe('useContextMenuItems', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might be missing a test to ensure the menu closes once clicked?
bae0640
to
fc243d0
Compare
Simplify ContextMenuItemGroup by removing originListener
…xt-menu-compass-ui
b0e0a69
to
e6e22cc
Compare
Ties #6937's context menu with leafygreen components and exposes that.