Skip to content
Open
Show file tree
Hide file tree
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
Expand Up @@ -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>

Expand Down
1 change: 1 addition & 0 deletions docs/examples/case.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const Demo = () => {
onPopupAlign={() => {
console.warn('Aligned!');
}}
hideContextMenuOnScroll={false}
>
<div
style={{
Expand Down
4 changes: 3 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -151,6 +152,7 @@ export function generateTrigger(
showAction: [],
hideAction: [],
autoDestroy: false,
hideContextMenuOnScroll: true,
};

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