Skip to content

Commit

Permalink
fix(legacy/dropdown): fix prefix-cls (#1514)
Browse files Browse the repository at this point in the history
* fix(legacy/dropdown): fix prefix-cls

* fix(popover): fix popover error

Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin committed Nov 23, 2021
1 parent a3bde92 commit 1b56d47
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/legacy/dropdown/style/index.less
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@import '../../../stylesheet/index.less';
@import '../../../stylesheet/mixin/trigger.less';

@dropdown-prefix-cls: ~'@{component-prefix}-dropdown';
@old-dropdown-prefix-cls: ~'@{component-prefix}-dropdown';
@dropdown-arrow-width: 0px;
@dropdown-distance: 0px;
@dropdown-duration: 10ms;

.@{dropdown-prefix-cls} {
.@{old-dropdown-prefix-cls} {
position: absolute;
z-index: 399;
margin: auto;
Expand Down Expand Up @@ -55,7 +55,7 @@
pointer-events: auto;
}
}
.trigger-placement(@dropdown-prefix-cls, @color-background-dropdown, @dropdown-arrow-width, @dropdown-distance);
.trigger-placement(@old-dropdown-prefix-cls, @color-background-dropdown, @dropdown-arrow-width, @dropdown-distance);
}

.trigger-transition(@dropdown-prefix-cls, @dropdown-duration);
.trigger-transition(@old-dropdown-prefix-cls, @dropdown-duration);
2 changes: 1 addition & 1 deletion src/legacy/selector-pro/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
box-shadow: 0 6px 14px rgba(223, 226, 237, 0.8);
}
.@{selector-prefix-cls}-overlay-dropdown {
.@{dropdown-prefix-cls}-inner {
.@{old-dropdown-prefix-cls}-inner {
overflow: visible;
}
}
8 changes: 5 additions & 3 deletions src/popover/Popover.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useMemo, useCallback, useEffect, useRef, useLayoutEffect } from 'react';
import classNames from 'classnames';
import { debounce, isUndefined } from 'lodash';
import { debounce, isUndefined, isFunction } from 'lodash';
import { usePopper } from 'react-popper';
import ReactDOM from 'react-dom';
import { PopoverProps, placements } from './interface';
Expand Down Expand Up @@ -87,8 +87,10 @@ const Popover = (props: PopoverProps) => {
const onDocumentClick = useCallback(
(event: MouseEvent) => {
const { target } = event;
if (!referenceElement?.contains(target as Node) && !popperElement?.contains(target as Node)) {
updateVisible(false);
if (isFunction(referenceElement?.contains) && isFunction(popperElement?.contains)) {
if (!referenceElement?.contains(target as Node) && !popperElement?.contains(target as Node)) {
updateVisible(false);
}
}
},
[popperElement, referenceElement, updateVisible]
Expand Down

1 comment on commit 1b56d47

@vercel
Copy link

@vercel vercel bot commented on 1b56d47 Nov 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.