DD fix
This commit is contained in:
parent
5453ee671f
commit
4d4767beb3
|
|
@ -27,12 +27,18 @@ let Dropdown = React.forwardRef(({ children, dropdownCss, onValueChanged, button
|
||||||
const [popoverDropdownRef, setPopoverDropdownRef] = React.useState(null);
|
const [popoverDropdownRef, setPopoverDropdownRef] = React.useState(null);
|
||||||
|
|
||||||
const { styles, attributes, update } = usePopper(btnDropdownRef, popoverDropdownRef,
|
const { styles, attributes, update } = usePopper(btnDropdownRef, popoverDropdownRef,
|
||||||
{ placement: placement ?? "bottom", ...popper });
|
{
|
||||||
|
placement: placement ?? "bottom",
|
||||||
|
strategy: "fixed",
|
||||||
|
...popper
|
||||||
|
});
|
||||||
|
|
||||||
const openDropdownPopover = async () => {
|
const openDropdownPopover = async () => {
|
||||||
setDropdownPopoverShow(true);
|
setDropdownPopoverShow(true);
|
||||||
console.log(update)
|
|
||||||
|
if (update != null) {
|
||||||
await update();
|
await update();
|
||||||
|
}
|
||||||
|
|
||||||
onValueChanged && onValueChanged(true);
|
onValueChanged && onValueChanged(true);
|
||||||
};
|
};
|
||||||
|
|
@ -43,7 +49,7 @@ let Dropdown = React.forwardRef(({ children, dropdownCss, onValueChanged, button
|
||||||
|
|
||||||
function handleOutsideClick(event) {
|
function handleOutsideClick(event) {
|
||||||
let node = popoverDropdownRef;
|
let node = popoverDropdownRef;
|
||||||
if (node && !node?.contains(event.target)) {
|
if (node && !node?.contains(event.target) && !btnDropdownRef?.contains(event.target)) {
|
||||||
closeDropdownPopover();
|
closeDropdownPopover();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -60,11 +66,11 @@ let Dropdown = React.forwardRef(({ children, dropdownCss, onValueChanged, button
|
||||||
document.removeEventListener("click", handleOutsideClick)
|
document.removeEventListener("click", handleOutsideClick)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
openDropdownPopover,
|
openDropdownPopover,
|
||||||
closeDropdownPopover
|
closeDropdownPopover
|
||||||
}))
|
}))*/
|
||||||
|
|
||||||
let childrenWithProps = React.Children.map(children, (item) => {
|
let childrenWithProps = React.Children.map(children, (item) => {
|
||||||
if (!item)
|
if (!item)
|
||||||
|
|
@ -88,8 +94,8 @@ let Dropdown = React.forwardRef(({ children, dropdownCss, onValueChanged, button
|
||||||
>
|
>
|
||||||
{button}
|
{button}
|
||||||
</button>
|
</button>
|
||||||
{dropdownPopoverShow &&
|
|
||||||
<div
|
{dropdownPopoverShow && <div
|
||||||
{...props}
|
{...props}
|
||||||
ref={setPopoverDropdownRef}
|
ref={setPopoverDropdownRef}
|
||||||
onMouseEnter={async () => { setOverDropDown(true); hover && await openDropdownPopover() }}
|
onMouseEnter={async () => { setOverDropDown(true); hover && await openDropdownPopover() }}
|
||||||
|
|
@ -97,14 +103,15 @@ let Dropdown = React.forwardRef(({ children, dropdownCss, onValueChanged, button
|
||||||
style={styles.popper}
|
style={styles.popper}
|
||||||
{...attributes.popper}
|
{...attributes.popper}
|
||||||
css={[
|
css={[
|
||||||
|
dropdownPopoverShow ? tw`block` : tw`hidden`,
|
||||||
tw`bg-trinary text-base z-50 float-left rounded-xl overflow-hidden text-left shadow-lg`,
|
tw`bg-trinary text-base z-50 float-left rounded-xl overflow-hidden text-left shadow-lg`,
|
||||||
dropdownCss,
|
dropdownCss,
|
||||||
props.css
|
props.css
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{childrenWithProps}
|
{childrenWithProps}
|
||||||
</div>
|
</div>}
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user