From 277db1bd8c4a5fdb22fab0f145c97778224aa1ff Mon Sep 17 00:00:00 2001 From: maziggy Date: Tue, 3 Mar 2026 11:24:04 +0100 Subject: [PATCH] Revert "Merge pull request #578 from aneopsy/fix-ams-slot" This reverts commit d4aa77f50240f461e4f24e7e72a7d03aee05ee55, reversing changes made to 82178f8abd3ff3ca55f79de4c0549f251e13ab69. --- .../src/components/ConfigureAmsSlotModal.tsx | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/ConfigureAmsSlotModal.tsx b/frontend/src/components/ConfigureAmsSlotModal.tsx index 2136fe40c..0e83d4dbc 100644 --- a/frontend/src/components/ConfigureAmsSlotModal.tsx +++ b/frontend/src/components/ConfigureAmsSlotModal.tsx @@ -1,4 +1,4 @@ -import { useState, useMemo, useEffect, useCallback, useRef } from 'react'; +import { useState, useMemo, useEffect, useCallback } from 'react'; import { useQuery, useMutation } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { X, Loader2, Settings2, ChevronDown, CheckCircle2, RotateCcw } from 'lucide-react'; @@ -242,7 +242,6 @@ export function ConfigureAmsSlotModal({ const [searchQuery, setSearchQuery] = useState(''); const [showSuccess, setShowSuccess] = useState(false); const [showExtendedColors, setShowExtendedColors] = useState(false); - const scrolledToRef = useRef(''); // Fetch cloud settings (gracefully handle 401 when logged out) const { data: cloudSettings, isLoading: settingsLoading, isError: cloudError } = useQuery({ @@ -736,7 +735,6 @@ export function ConfigureAmsSlotModal({ setColorInput(''); setSearchQuery(''); setShowSuccess(false); - scrolledToRef.current = ''; } }, [isOpen, slotInfo.savedPresetId, slotInfo.trayInfoIdx, slotInfo.trayColor, cloudSettings?.filament]); @@ -772,17 +770,6 @@ export function ConfigureAmsSlotModal({ } }, [isOpen, handleKeyDown]); - // Scroll selected preset into view only when the selection changes (not on every render). - // Inline callback refs cause scrollIntoView to fire every render, which on Windows - // creates an infinite scroll loop due to scroll → re-render → scrollIntoView cycles. - useEffect(() => { - if (selectedPresetId && selectedPresetId !== scrolledToRef.current) { - scrolledToRef.current = selectedPresetId; - const el = document.querySelector(`[data-preset-id="${CSS.escape(selectedPresetId)}"]`); - el?.scrollIntoView({ block: 'nearest' }); - } - }, [selectedPresetId]); - if (!isOpen) return null; const isLoading = (settingsLoading && !cloudError) || localLoading || builtinLoading || kprofilesLoading; @@ -902,7 +889,9 @@ export function ConfigureAmsSlotModal({ filteredPresets.map((preset) => (