mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-04-06 01:25:33 +00:00
fix select position toast
This commit is contained in:
parent
aa9293104d
commit
fba5fd9845
@ -1,6 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
import { useState } from 'react'
|
import { DomEvent } from 'leaflet'
|
||||||
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import SVG from 'react-inlinesvg'
|
import SVG from 'react-inlinesvg'
|
||||||
|
|
||||||
import PlusSVG from '#assets/plus.svg'
|
import PlusSVG from '#assets/plus.svg'
|
||||||
@ -20,6 +21,14 @@ export default function AddButton({
|
|||||||
const { width } = useWindowDimensions()
|
const { width } = useWindowDimensions()
|
||||||
const isMobile = width < 768
|
const isMobile = width < 768
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
const [isOpen, setIsOpen] = useState(false)
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (containerRef.current) {
|
||||||
|
DomEvent.disableClickPropagation(containerRef.current)
|
||||||
|
DomEvent.disableScrollPropagation(containerRef.current)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
const canAddItems = () => {
|
const canAddItems = () => {
|
||||||
let canAdd = false
|
let canAdd = false
|
||||||
@ -39,6 +48,7 @@ export default function AddButton({
|
|||||||
<>
|
<>
|
||||||
{canAddItems() ? (
|
{canAddItems() ? (
|
||||||
<div
|
<div
|
||||||
|
ref={containerRef}
|
||||||
className={`tw:dropdown tw:dropdown-top tw:dropdown-end ${!isMobile ? 'tw:dropdown-hover' : ''} tw:z-500 tw:absolute tw:right-4 tw:bottom-4 ${isOpen ? 'tw:dropdown-open' : ''}`}
|
className={`tw:dropdown tw:dropdown-top tw:dropdown-end ${!isMobile ? 'tw:dropdown-hover' : ''} tw:z-500 tw:absolute tw:right-4 tw:bottom-4 ${isOpen ? 'tw:dropdown-open' : ''}`}
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user