fix side tree not hiding the visible window when everything is visible
This commit is contained in:
@@ -68,7 +68,6 @@ async function getMetadata(source: ChainSource): Promise<AnyMetadata> {
|
||||
const provider = getProvider(source)
|
||||
const client = createClient(provider)
|
||||
|
||||
console.log("loading metadata")
|
||||
const metadata = await new Promise<AnyMetadata>((resolve, reject) => {
|
||||
const chainHead = client.chainHead(
|
||||
true,
|
||||
@@ -100,7 +99,6 @@ async function getMetadata(source: ChainSource): Promise<AnyMetadata> {
|
||||
)
|
||||
})
|
||||
|
||||
console.log("received", metadata)
|
||||
client.destroy()
|
||||
return metadata
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ export const SearchableSelect = <T,>({
|
||||
}
|
||||
onChange={(event) => setQuery(event.target.value)}
|
||||
placeholder="Select"
|
||||
autoComplete="off"
|
||||
/>
|
||||
<ComboboxButton className="group">
|
||||
<ChevronDown className="size-4 " />
|
||||
|
||||
@@ -87,9 +87,7 @@ export const EditMode: React.FC<{
|
||||
>
|
||||
<div className="relative">
|
||||
{!innerValue.value ? (
|
||||
<div className="h-14 ml-5 text-sm flex flex-col justify-center">
|
||||
{"Start by choosing a value -->"}
|
||||
</div>
|
||||
<div className="text-sm text-slate-400">(Empty)</div>
|
||||
) : (
|
||||
<TreeCodec {...props} />
|
||||
)}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
FC,
|
||||
PropsWithChildren,
|
||||
useContext,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react"
|
||||
@@ -85,16 +86,32 @@ export const MarkersContextProvider: FC<PropsWithChildren> = ({ children }) => {
|
||||
)
|
||||
}
|
||||
|
||||
const useWindowTransition = (isAllVisible: boolean) => {
|
||||
const wasOff = useRef(false)
|
||||
|
||||
useEffect(() => {
|
||||
wasOff.current = isAllVisible
|
||||
}, [isAllVisible])
|
||||
|
||||
return !isAllVisible || !wasOff.current
|
||||
}
|
||||
export const VisibleWindow = () => {
|
||||
const ctx = useContext(MarkersContext)
|
||||
const [height, setHeight] = useState<number | null>(null)
|
||||
const ref = useHeightObserver(setHeight)
|
||||
|
||||
const isAllVisible = // 🔫 always has been
|
||||
!!ctx &&
|
||||
((Math.round(ctx.range[0]) === 0 &&
|
||||
Math.round(ctx.range[1]) === Math.round(height ?? NaN)) ||
|
||||
ctx.range[1] === 0)
|
||||
const transitionEnabled = useWindowTransition(isAllVisible)
|
||||
if (!ctx) return null
|
||||
|
||||
const isAllVisible = ctx.range[0] === 0 && ctx.range[1] === height // 🔫 always has been
|
||||
|
||||
const fade =
|
||||
"absolute left-0 right-0 transition-all ease-linear bg-gray-100 bg-opacity-10 backdrop-blur-[0.4px]"
|
||||
const fade = twMerge(
|
||||
"absolute left-0 right-0 ease-linear bg-gray-100 bg-opacity-10 backdrop-blur-[0.4px]",
|
||||
transitionEnabled && "transition-all",
|
||||
)
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user