Skip to content

Commit aed37d1

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
fix: resolve visualize button clipping and event propagation
1 parent 0f0aeeb commit aed37d1

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/components/dashboard/SpreadsheetTable.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ const SpreadsheetTableComponent = ({ node, editor, getPos, deleteNode }: any) =>
166166
setShowChartPreview(false);
167167
};
168168

169+
const toggleChartPreview = (e: React.MouseEvent) => {
170+
e.preventDefault();
171+
e.stopPropagation();
172+
setShowChartPreview(!showChartPreview);
173+
};
174+
169175
return (
170176
<NodeViewWrapper className="spreadsheet-premium-wrapper my-12 group/spreadsheet relative">
171177
<div className="bg-white border border-neutral-200 rounded-xl overflow-hidden shadow-2xl transition-all group-hover/spreadsheet:border-neutral-300">
@@ -195,7 +201,7 @@ const SpreadsheetTableComponent = ({ node, editor, getPos, deleteNode }: any) =>
195201
</div>
196202

197203
{/* TOOLBAR: Formatting & Alignment */}
198-
<div className="flex items-center gap-1 px-3 py-1.5 bg-[#f8f9fa] border-b border-neutral-200 overflow-x-auto no-scrollbar">
204+
<div className="flex items-center gap-1 px-3 py-1.5 bg-[#f8f9fa] border-b border-neutral-200 relative z-40">
199205
<div className="flex items-center gap-0.5 pr-2 border-r border-neutral-200">
200206
<button onMouseDown={(e) => toolbarAction(e, 'bold')} className="p-1.5 hover:bg-neutral-200 text-neutral-700 rounded transition-colors"><Bold className="w-3.5 h-3.5" /></button>
201207
<button onMouseDown={(e) => toolbarAction(e, 'italic')} className="p-1.5 hover:bg-neutral-200 text-neutral-700 rounded transition-colors"><Italic className="w-3.5 h-3.5" /></button>
@@ -220,16 +226,19 @@ const SpreadsheetTableComponent = ({ node, editor, getPos, deleteNode }: any) =>
220226
{/* Chart Creator Dropdown */}
221227
<div className="relative">
222228
<button
223-
onMouseDown={(e) => { e.preventDefault(); setShowChartPreview(!showChartPreview); }}
224-
className={`flex items-center gap-1.5 px-3 py-1 ml-1 rounded transition-all text-[10px] font-bold ${showChartPreview ? 'bg-blue-600 text-white' : 'bg-blue-50 text-blue-600 hover:bg-blue-100'}`}
229+
onMouseDown={toggleChartPreview}
230+
className={`flex items-center gap-1.5 px-3 py-1.5 ml-1 rounded-lg transition-all text-[10px] font-bold ${showChartPreview ? 'bg-blue-600 text-white shadow-lg shadow-blue-500/30' : 'bg-blue-50 text-blue-600 hover:bg-blue-100'}`}
225231
>
226232
<BarChart2 className="w-3.5 h-3.5" />
227233
<span>Visualize</span>
228234
<ChevronDown className={`w-3 h-3 transition-transform ${showChartPreview ? 'rotate-180' : ''}`} />
229235
</button>
230236

231237
{showChartPreview && (
232-
<div className="absolute top-full right-0 mt-2 w-64 bg-white border border-neutral-200 rounded-xl shadow-2xl p-4 z-50 animate-in fade-in slide-in-from-top-2">
238+
<div
239+
className="absolute top-full left-0 mt-2 w-72 bg-white border border-neutral-200 rounded-xl shadow-[0_20px_50px_rgba(0,0,0,0.15)] p-4 z-[9999] animate-in fade-in slide-in-from-top-2"
240+
onMouseDown={(e) => e.stopPropagation()}
241+
>
233242
<div className="flex items-center justify-between mb-4">
234243
<h4 className="text-xs font-bold text-neutral-800 uppercase tracking-wider">Chart Settings</h4>
235244
<button onClick={() => setShowChartPreview(false)} className="text-neutral-400 hover:text-neutral-600"><X className="w-4 h-4" /></button>

0 commit comments

Comments
 (0)