ui: fix calendar self-close
This commit is contained in:
parent
bd2a59266d
commit
1cca40d4c5
2 changed files with 12 additions and 3 deletions
|
|
@ -15,7 +15,6 @@ function WidgetDateRange({
|
||||||
hasComparison = false,
|
hasComparison = false,
|
||||||
presetComparison = null,
|
presetComparison = null,
|
||||||
}: any) {
|
}: any) {
|
||||||
const { t } = useTranslation();
|
|
||||||
const { dashboardStore, metricStore } = useStore();
|
const { dashboardStore, metricStore } = useStore();
|
||||||
const density = dashboardStore.selectedDensity;
|
const density = dashboardStore.selectedDensity;
|
||||||
const onDensityChange = (density: number) => {
|
const onDensityChange = (density: number) => {
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,7 @@ function AndDateRange({
|
||||||
onApplyDateRange,
|
onApplyDateRange,
|
||||||
isTileDisabled,
|
isTileDisabled,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
|
const customRangeRef = React.useRef(null);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const menuProps = {
|
const menuProps = {
|
||||||
items: options.map((opt: any) => ({
|
items: options.map((opt: any) => ({
|
||||||
|
|
@ -280,22 +281,31 @@ function AndDateRange({
|
||||||
{isCustom && (
|
{isCustom && (
|
||||||
<OutsideClickDetectingDiv
|
<OutsideClickDetectingDiv
|
||||||
onClickOutside={(e: any) => {
|
onClickOutside={(e: any) => {
|
||||||
|
if (customRangeRef.current && customRangeRef.current.contains(e.target)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
e.target.className.includes('react-calendar') ||
|
e.target.className.includes('react-calendar') ||
|
||||||
|
e.target.className.includes('ant-picker')
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
e.target.parentElement.parentElement.classList.contains(
|
e.target.parentElement.parentElement.classList.contains(
|
||||||
'rc-time-picker-panel-select',
|
'rc-time-picker-panel-select',
|
||||||
) ||
|
) ||
|
||||||
e.target.parentElement.parentElement.classList[0]?.includes(
|
e.target.parentElement.parentElement.classList[0]?.includes(
|
||||||
'-menu',
|
'-menu',
|
||||||
) ||
|
) ||
|
||||||
e.target.className.includes('ant-picker')
|
e.target.parentElement.className.includes('react-calendar')
|
||||||
) {
|
) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
setIsCustom(false);
|
setIsCustom(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
ref={customRangeRef}
|
||||||
className={cn(
|
className={cn(
|
||||||
'absolute top-0 mt-10 z-40',
|
'absolute top-0 mt-10 z-40',
|
||||||
right ? 'right-0' : 'left-0',
|
right ? 'right-0' : 'left-0',
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue