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

AG-10486 Contextmenu callback type-safety and docs #1614

Merged
merged 6 commits into from
May 30, 2024

Conversation

olegat
Copy link
Collaborator

@olegat olegat commented May 23, 2024

@olegat olegat marked this pull request as ready for review May 23, 2024 15:54
@olegat olegat requested review from alantreadway, rmc-software and a team as code owners May 23, 2024 15:54
@olegat olegat marked this pull request as draft May 23, 2024 15:55
@olegat olegat force-pushed the AG-10486/contextmenu_typesafetly_and_docs branch 2 times, most recently from cc0d975 to 546335e Compare May 29, 2024 09:18
@olegat olegat marked this pull request as ready for review May 29, 2024 09:19
@@ -33,17 +32,17 @@ export class ContextMenu extends _ModuleSupport.BaseModuleInstance implements _M
/**
* Extra menu actions with a label and callback.
*/
public extraActions: Array<ContextMenuAction> = [];
public extraActions: NonNullable<AgContextMenuOptions['extraActions']> = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think we're generally trying to separate options types and modules/features types, even if it produces a bit of duplication?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

We still do this: The internal state is stored in ContextMenu.groups, whereas ContextMenu.extraActions stores the input user options.

private readonly groups: ContextMenuGroups;

The ContextMenu.groups property contains some duplicated values like label and action, but it also contains internal meta-data like id? and type:

The legend context menu callbacks were apparently being called with the
incorrection parameter type. This change solves that and enforces type-
safely when invoking context menu callback.
Note: This is a breaking change because the event.type string in the
option contract is changing.
This fixes extraNodeActions and extraLegendItemActions.
@olegat olegat force-pushed the AG-10486/contextmenu_typesafetly_and_docs branch from 546335e to b297274 Compare May 29, 2024 17:23
Copy link
Member

@alantreadway alantreadway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alantreadway alantreadway merged commit 95471fd into latest May 30, 2024
11 checks passed
@alantreadway alantreadway deleted the AG-10486/contextmenu_typesafetly_and_docs branch May 30, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants