mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Restore default context menu out of std views
Summary: Also fix few clode glitches - Attach events handler to the scrollPane using `onMatch` instead of the cell itself. This streamline cell dom creation a bit while scrolling. - Fix memory leaks on contextMenu. - Also fix Importer and ColumnOps nbrowser test see: https://phab.getgrist.com/D3237#inline-36376 https://phab.getgrist.com/D3237#inline-36375 Restore default context menu for where there's no custom one It appears that default context menu adds some value, in particular for links and for editing text. This diff restores it. Test Plan: Should not break anything. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3256
This commit is contained in:
@@ -30,10 +30,7 @@ export function createAppUI(topAppModel: TopAppModel, appObj: App): IDisposable
|
||||
dom.update(document.body, content, {
|
||||
// Cancel out bootstrap's overrides.
|
||||
style: 'font-family: inherit; font-size: inherit; line-height: inherit;'
|
||||
},
|
||||
// prevent default context menu to show
|
||||
dom.on('contextmenu', (ev) => ev.preventDefault())
|
||||
);
|
||||
});
|
||||
|
||||
function dispose() {
|
||||
// Return value of dom.maybe() / dom.domComputed() is a pair of markers with a function that
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* context menu) dont forget to prevent it by including below line at the root of the dom:
|
||||
* `dom.on('contextmenu', ev => ev.preventDefault())`
|
||||
*/
|
||||
import { Disposable, dom, DomArg, DomContents } from "grainjs";
|
||||
import { Disposable, dom, DomArg, DomContents, Holder } from "grainjs";
|
||||
import { cssMenuElem } from 'app/client/ui2018/menus';
|
||||
import { IOpenController, Menu } from 'popweasel';
|
||||
|
||||
@@ -77,22 +77,17 @@ class ContextMenuController extends Disposable implements IOpenController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the return value of contentFunc() in a context menu next to the mouse.
|
||||
*/
|
||||
function showContextMenu(ev: MouseEvent, contentFunc: IContextMenuContentFunc) {
|
||||
return ContextMenuController.create(null, ev, contentFunc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a context menu on contextmenu.
|
||||
*/
|
||||
export function contextMenu(contentFunc: IContextMenuContentFunc): DomArg {
|
||||
return (elem) => {
|
||||
const holder = Holder.create(null);
|
||||
dom.autoDisposeElem(elem, holder);
|
||||
dom.onElem(elem, 'contextmenu', (ev) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
dom.autoDisposeElem(elem, showContextMenu(ev, contentFunc));
|
||||
ContextMenuController.create(holder, ev, contentFunc);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user