From 9617dd46d00d3d22d3b96fcf2ca260f377e14efa Mon Sep 17 00:00:00 2001 From: mainhanu Date: Tue, 31 May 2022 08:42:55 +0800 Subject: [PATCH] feat: support hideContextMenuOnScroll option --- README.md | 6 ++++++ docs/examples/case.tsx | 1 + src/index.tsx | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c2684c2e..f1ff180d 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,12 @@ npm start Let popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth') + + hideContextMenuOnScroll + boolean + true + close popup when trigger type contains 'onContextMenu' and document is scrolling + diff --git a/docs/examples/case.tsx b/docs/examples/case.tsx index 2d24a8e4..168e375a 100644 --- a/docs/examples/case.tsx +++ b/docs/examples/case.tsx @@ -217,6 +217,7 @@ const Demo = () => { onPopupAlign={() => { console.warn('Aligned!'); }} + hideContextMenuOnScroll={false} >
(); @@ -240,7 +242,7 @@ export function generateTrigger( ); } // close popup when trigger type contains 'onContextMenu' and document is scrolling. - if (!this.contextMenuOutsideHandler1 && this.isContextMenuToShow()) { + if (props.hideContextMenuOnScroll && !this.contextMenuOutsideHandler1 && this.isContextMenuToShow()) { currentDocument = currentDocument || props.getDocument(this.getRootDomNode()); this.contextMenuOutsideHandler1 = addEventListener(