Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

fix(flyout): collapse copy indicator style flyout with spring animation on tab switch or settings exit

Deepender256420857744ae
diff --git a/src/components/IndicatorStyleFlyout.tsx b/src/components/IndicatorStyleFlyout.tsx
index e774a25..ea66a39 100644
--- a/src/components/IndicatorStyleFlyout.tsx
+++ b/src/components/IndicatorStyleFlyout.tsx
@@ -21,14 +21,18 @@ export function IndicatorStyleFlyout({ isRight }: { isRight: boolean }) {
const { t } = useTranslation()
const styleFlyoutOpen = useStore((s) => s.styleFlyoutOpen)
const setStyleFlyoutOpen = useStore((s) => s.setStyleFlyoutOpen)
+ const settingsOpen = useStore((s) => s.settingsOpen)
+ const open = useStore((s) => s.open)
const settings = useStore((s) => s.settings)
const patch = useStore((s) => s.patchSettings)
const adaptiveSpring = useAdaptiveSpring()
+ const isVisible = styleFlyoutOpen && settingsOpen && open
+
const flyoutRef = useRef<HTMLDivElement | null>(null)
useEffect(() => {
- if (!styleFlyoutOpen || !flyoutRef.current) {
+ if (!isVisible || !flyoutRef.current) {
useStore.getState().setPreviewFlyoutRect(null)
return
}
@@ -50,7 +54,7 @@ export function IndicatorStyleFlyout({ isRight }: { isRight: boolean }) {
window.removeEventListener('resize', updateRect)
useStore.getState().setPreviewFlyoutRect(null)
}
- }, [styleFlyoutOpen])
+ }, [isVisible])
const screenH = typeof window !== 'undefined' ? window.innerHeight : 800
const pFrac = settings.panelHeight || 0.6
@@ -83,7 +87,7 @@ export function IndicatorStyleFlyout({ isRight }: { isRight: boolean }) {
window.edge.setPreviewMode(false)
}
}}>
- {styleFlyoutOpen && (
+ {isVisible && (
<motion.div
ref={flyoutRef}
key="indicator-style-flyout"
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index 191e314..74e7b92 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -89,6 +89,9 @@ export function Settings({ inlineIndicatorStyle }: { inlineIndicatorStyle?: bool
const handleTabSwitch = (newTab: SettingsTab) => {
if (newTab === activeTab) return
+ if (styleFlyoutOpen) {
+ setStyleFlyoutOpen(false)
+ }
// Save current section's scroll position
if (scrollListRef.current) {
tabScrollPositions.current[activeTab] = scrollListRef.current.scrollTop
@@ -97,6 +100,15 @@ export function Settings({ inlineIndicatorStyle }: { inlineIndicatorStyle?: bool
setActiveTab(newTab)
}
+ // Close flyout if settings closes or unmounts
+ useEffect(() => {
+ return () => {
+ if (useStore.getState().styleFlyoutOpen) {
+ useStore.getState().setStyleFlyoutOpen(false)
+ }
+ }
+ }, [])
+
// Restore target section's independent scroll position when tab changes
useEffect(() => {
if (scrollListRef.current) {
diff --git a/src/store/appStore.ts b/src/store/appStore.ts
index 194751d..40f6d8c 100644
--- a/src/store/appStore.ts
+++ b/src/store/appStore.ts
@@ -261,14 +261,10 @@ export const useStore = create<AppState>((set, get) => ({
set({
settingsOpen,
settingsSubView: 'main',
- ...(settingsOpen
- ? {
- previewItemId: null,
- previewItemRect: null,
- previewFlyoutRect: null,
- styleFlyoutOpen: false
- }
- : {})
+ previewItemId: null,
+ previewItemRect: null,
+ previewFlyoutRect: null,
+ styleFlyoutOpen: false
})
},
setDragActive: (dragActive) => set({ dragActive }),