Skip to content

Fix onMouseDown event propagation, unstable gradient IDs, and TypeScript errors#114

Merged
fseehawer merged 3 commits intomasterfrom
copilot/fix-issues-in-code
Mar 6, 2026
Merged

Fix onMouseDown event propagation, unstable gradient IDs, and TypeScript errors#114
fseehawer merged 3 commits intomasterfrom
copilot/fix-issues-in-code

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

Several bugs and type errors existed across Svg, App, and missing type declarations — including a runtime crash path and a React anti-pattern.

src/Svg/index.tsx

  • Runtime bug: onMouseDown(event) was called as onMouseDown() — dropping the event. CircularSlider.onMouseDown calls event.preventDefault() / event.stopPropagation(), so this throws a TypeError at runtime when trackDraggable is enabled and a click is processed mid-drag.
  • Anti-pattern: Math.random() was called on every render to produce the SVG gradient ID. Moved to useRef so the ID is stable across re-renders — avoids unnecessary reconciliation and flickering in StrictMode.
// Before — new ID on every render, onMouseDown called without event
const gradientId = `radial-${label}-${Math.random()...}`;
onMouseDown();

// After — stable ID, event correctly forwarded
const gradientIdRef = useRef(`radial-${label}-${Math.random()...}`);
onMouseDown(event);

src/App.tsx

  • Typed sliderRefs as React.useRef<React.RefObject<CircularSliderHandle | null>[]> with createRef<CircularSliderHandle>() — fixes the four ref= TS2322 errors and enables ref.current.refresh() access.
  • Added explicit (index: number) to handleTabChange — removes implicit any.
  • Annotated styles as Record<string, React.CSSProperties> — resolves TS2322 on CSS properties (flexWrap, textAlign, overflowX) inferred as string.
  • Replaced deprecated border="0" HTML attribute on <input> and <img> with style={{ border: 0 }}.

src/vite-env.d.ts (new)

Added type declaration for *.svg?react Vite/SVGR imports — resolves TS2307 module-not-found errors for DragIcon and EmojiIcon.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 6, 2026 10:19
Co-authored-by: fseehawer <30494175+fseehawer@users.noreply.github.com>
…nents

Co-authored-by: fseehawer <30494175+fseehawer@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix identified issues in the code Fix onMouseDown event propagation, unstable gradient IDs, and TypeScript errors Mar 6, 2026
@fseehawer fseehawer marked this pull request as ready for review March 6, 2026 10:32
@fseehawer fseehawer merged commit e90f798 into master Mar 6, 2026
3 checks passed
@fseehawer fseehawer deleted the copilot/fix-issues-in-code branch March 6, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants