Skip to content

support hideContextMenuOnScroll option #300

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -247,6 +247,12 @@ npm start
<td></td>
<td>Let popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth')</td>
</tr>
<tr>
<td>hideContextMenuOnScroll</td>
<td>boolean</td>
<td>true</td>
<td>close popup when trigger type contains 'onContextMenu' and document is scrolling</td>
</tr>
</tbody>
</table>

1 change: 1 addition & 0 deletions docs/examples/case.tsx
Original file line number Diff line number Diff line change
@@ -217,6 +217,7 @@ const Demo = () => {
onPopupAlign={() => {
console.warn('Aligned!');
}}
hideContextMenuOnScroll={false}
>
<div
style={{
4 changes: 3 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -84,6 +84,7 @@ export interface TriggerProps {
popupVisible?: boolean;
defaultPopupVisible?: boolean;
autoDestroy?: boolean;
hideContextMenuOnScroll?: boolean;

stretch?: string;
alignPoint?: boolean; // Maybe we can support user pass position in the future
@@ -151,6 +152,7 @@ export function generateTrigger(
showAction: [],
hideAction: [],
autoDestroy: false,
hideContextMenuOnScroll: true,
};

popupRef = React.createRef<PopupInnerRef>();
@@ -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(