Closed Jamlearner closed 6 years ago
I think it used to, but there isn't an API for doing it now.
The best workaround is to programmatically trigger a click
event on the document.
document.dispatchEvent(new Event('click'))
That's a good workaround. Thanks @isaacplmann
@isaacplmann Just curious that why I am unable to call the methods directly inside this package?
// import { ContextMenuService } from 'ngx-contextmenu/public_api';
Then in constructor
constructor(
// public contextMenuService: ContextMenuService,
)
Explicitly call the method:
public onClearContextMenu() {
// const keyEvent = new KeyboardEvent('keydown', { key: 'Escape' });
// if (this.contextMenuService) {
// this.contextMenuService.closeAllContextMenus({
// eventType: 'cancel',
// event: keyEvent
// });
// }
}
There is no error in IDE but an error when try to build or serve: Module not found: Error: Can't resolve 'ngx-contextmenu/public_api' in 'my component.ts'
Try
import { ContextMenuService } from 'ngx-contextmenu';
I think it used to, but there isn't an API for doing it now.
The best workaround is to programmatically trigger a
click
event on the document.document.dispatchEvent(new Event('click'))
There used to be a triggerClose Subject on the ContextMenuService but that no longer works. In the code I find no references to triggerClose other than the definition. See #38. Instead I now use closeAllContextMenus(...).
There is a case where I am using a table-renderer package with scroll bars. In that element, I am unable to close contextmenu when attempt to scroll (Using mousewheel or dragging scrollbar). Due to the limitation on not having any way to put
cdkScrollable
on the element.Does ngx-contextmenu provides API to do a manual closing?