Skip to content
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

fix: make context menu renderer arguments required #4918

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/context-menu/src/vaadin-context-menu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export interface ContextMenuRendererContext {

export type ContextMenuRenderer = (
root: HTMLElement,
contextMenu?: ContextMenu,
context?: ContextMenuRendererContext,
contextMenu: ContextMenu,
context: ContextMenuRendererContext,
) => void;

/**
Expand Down
12 changes: 12 additions & 0 deletions packages/context-menu/test/typings/context-menu.types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import '../../vaadin-context-menu.js';
import type {
ContextMenu,
ContextMenuItem,
ContextMenuItemSelectedEvent,
ContextMenuOpenedChangedEvent,
ContextMenuRenderer,
ContextMenuRendererContext,
} from '../../vaadin-context-menu.js';

const menu = document.createElement('vaadin-context-menu');
Expand All @@ -18,3 +21,12 @@ menu.addEventListener('item-selected', (event) => {
assertType<ContextMenuItemSelectedEvent>(event);
assertType<ContextMenuItem>(event.detail.value);
});

const renderer: ContextMenuRenderer = (root, contextMenu, context) => {
assertType<HTMLElement>(root);
assertType<ContextMenu>(contextMenu);
assertType<ContextMenuRendererContext>(context);
assertType<HTMLElement>(context.target);
};

menu.renderer = renderer;