From dcbaaea05511dabfdd96921f1adb3137d26a88f6 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Fri, 24 Apr 2026 20:19:01 +0200 Subject: [PATCH] fix: resolve white screen crash in PricingView filters by adding comprehensive safety checks --- src/components/ColumnFilterPopover.tsx | 23 +++++++----- src/components/PricingView.tsx | 51 +++++++++++++------------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/components/ColumnFilterPopover.tsx b/src/components/ColumnFilterPopover.tsx index 25ed587..8d5dde4 100644 --- a/src/components/ColumnFilterPopover.tsx +++ b/src/components/ColumnFilterPopover.tsx @@ -21,6 +21,7 @@ interface ColumnFilterPopoverProps { title?: string; className?: string; zIndex?: number; + triggerId?: string; } export function ColumnFilterPopover({ @@ -73,8 +74,10 @@ export function ColumnFilterPopover({ const isDraggingRef = React.useRef(false); const dragStartRef = React.useRef(null); + const safeUniqueValues = uniqueValues || []; + const safeSelectedValues = selectedValues || []; const hoveredIndexRef = React.useRef(null); - const selectedValuesRef = React.useRef(selectedValues); + const selectedValuesRef = React.useRef(safeSelectedValues); const onSelectAllRef = React.useRef(onSelectAll); const filteredValuesRef = React.useRef([]); const didDragRef = React.useRef(false); @@ -85,16 +88,16 @@ export function ColumnFilterPopover({ const listRef = React.useRef(null); const filteredValues = useMemo(() => { - return uniqueValues.filter(v => + return safeUniqueValues.filter(v => String(v || '').toLowerCase().includes(search.toLowerCase()) ); - }, [uniqueValues, search]); + }, [safeUniqueValues, search]); filteredValuesRef.current = filteredValues; - selectedValuesRef.current = selectedValues; + selectedValuesRef.current = safeSelectedValues; onSelectAllRef.current = onSelectAll; - const isAllSelected = selectedValues.length === uniqueValues.length && uniqueValues.length > 0; + const isAllSelected = safeSelectedValues.length === safeUniqueValues.length && safeUniqueValues.length > 0; const applyCondition = () => { const results: string[] = []; @@ -221,7 +224,7 @@ export function ColumnFilterPopover({ activeTab === 'values' ? "bg-blue-600 text-white" : "text-slate-400 hover:text-white" )} > - Values ({selectedValues.length}) + Values ({safeSelectedValues.length}) @@ -1318,8 +1318,8 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, {openFilter === 'productType' && ( setProductTypeFilter((prev: string[]) => prev.includes(val) ? prev.filter((v: string) => v !== val) : [...prev, val])} onSelectAll={vals => setProductTypeFilter(vals)} onClear={() => { setProductTypeFilter([]); setOpenFilter(null); }} @@ -1380,7 +1380,7 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, setDynamicColFilters(prev => { const current = prev[col.index] || []; return current.includes(val) @@ -2150,7 +2150,8 @@ function TextFilterPopover({ value, onChange, onClose, triggerId }: { , - document.body && document.body); + document.body + ); } // ── Sort Icon Helper ───────────────────────────────────────────────────