-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Should commands receive an event that triggered them? #554
Comments
Link to the code mentioned above: lumino/packages/widgets/src/menu.ts Line 316 in 133d872
Somehow related for the discussion: #180 |
During the team call an issue of serialisation of commands (e.g. in interface INodeData {
boundingBox: {x: number; y: number; height: number; width: number};
htmlString: string;
selector: string;
classNames: readonly string[];
}
interface IEvent {
target?: INodeData
// other common event data
}
thoughts? CC @afshin |
Problem
A number of commands, e.g. in jupterlab extensions (especially editor integrations such as spellchecker or LSP), need to know the node they were triggered on. Currently JupyterLab implements a custom caching logic that holds the most recent pointer event that triggered the context menu forever (until another context menu gets opened). This leads to a memory leak.
Proposed Solution
We could reserve a special argument in the args of commands for the event the command was triggered by (if any). Since most events contain a
target
property this would solve a major headache of extension developers.This would mean that calls to
CommandRegistry.execute
would need to be adjusted to pass the event on. Conceptually this could be something like:but in practice we would probably want to adjust the signature of
execute
to avoid repetition of this operation. We would also want to make similar adjustments inisEnabled
and similar methods.Additional context
The text was updated successfully, but these errors were encountered: