mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vmui: fix display Popper.tsx (#5842)
* vmui: fix display Popper.tsx * vmui/docs: fix display Popper.tsx --------- Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
This commit is contained in:
parent
348eec39ba
commit
9e44870d5c
2 changed files with 13 additions and 8 deletions
|
@ -7,7 +7,6 @@ import useDeviceDetect from "../../../hooks/useDeviceDetect";
|
|||
import Button from "../Button/Button";
|
||||
import { CloseIcon } from "../Icons";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import useBoolean from "../../../hooks/useBoolean";
|
||||
import useEventListener from "../../../hooks/useEventListener";
|
||||
import { useCallback } from "preact/compat";
|
||||
|
||||
|
@ -43,12 +42,7 @@ const Popper: FC<PopperProps> = ({
|
|||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const [popperSize, setPopperSize] = useState({ width: 0, height: 0 });
|
||||
|
||||
const {
|
||||
value: isOpen,
|
||||
setValue: setIsOpen,
|
||||
setFalse: handleClose,
|
||||
} = useBoolean(false);
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const popperRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
|
@ -113,6 +107,7 @@ const Popper: FC<PopperProps> = ({
|
|||
|
||||
if (fullWidth) position.width = `${buttonPos.width}px`;
|
||||
if (position.top < 0) position.top = 20;
|
||||
if (position.left < 0) position.left = 20;
|
||||
|
||||
return position;
|
||||
},[buttonRef, placement, isOpen, children, fullWidth]);
|
||||
|
@ -122,7 +117,15 @@ const Popper: FC<PopperProps> = ({
|
|||
onClose();
|
||||
};
|
||||
|
||||
if (clickOutside) useClickOutside(popperRef, () => setIsOpen(false), buttonRef);
|
||||
const handleClose = () => {
|
||||
setIsOpen(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleClickOutside = () => {
|
||||
if (!clickOutside) return;
|
||||
handleClose();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!popperRef.current || !isOpen || (isMobile && !disabledFullScreen)) return;
|
||||
|
@ -142,6 +145,7 @@ const Popper: FC<PopperProps> = ({
|
|||
|
||||
useEventListener("scroll", handleClose);
|
||||
useEventListener("popstate", handlePopstate);
|
||||
useClickOutside(popperRef, handleClickOutside, buttonRef);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -45,6 +45,7 @@ See also [LTS releases](https://docs.victoriametrics.com/LTS-releases.html).
|
|||
or [/api/v1/query_range](https://docs.victoriametrics.com/keyconcepts/#range-query). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5795).
|
||||
* BUGFIX: [Single-node VictoriaMetrics](https://docs.victoriametrics.com/) and `vmselect` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/cluster-victoriametrics/): fixed floating-point error when parsing time in RFC3339 format. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5801) for details.
|
||||
* BUGFIX: [vmalert](https://docs.victoriametrics.com/#vmalert): consistently sort groups by name and filename on `/groups` page in UI. This should prevent non-deterministic sorting for groups with identical names.
|
||||
* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix Popper display issues. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5842).
|
||||
* BUGFIX: [vmselect](https://docs.victoriametrics.com/): format time with milliseconds precision when `__timestamp__:rfc3339` is specified for [/api/v1/export/csv](https://docs.victoriametrics.com/#how-to-export-csv-data) API response. See this [issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5837) for details.
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue