fuse without voltageRating renders a bare unit: "1A / V" on the schematic, "V" in circuit JSON
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 58
- Forks
- 203
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 286
Description
What happens
A <fuse /> without voltageRating renders a bare unit with no number — on the schematic symbol and in circuit JSON:
<fuse name="F1" currentRating="1A" footprint="0402" />
source_component.display_current_rating "1A"
source_component.display_voltage_rating "V" ← no value
schematic_component.symbol_display_value "1A / V" ← rendered on the schematic
voltageRating is optional in the props schema (voltageRating?: number | string), while currentRating is required — a fuse without a currentRating fails validation outright (Invalid props for fuse "F4": currentRating (Required)). So "current only" is a fully supported, and probably common, way to declare a fuse, and it's the case that renders wrong.
Cause
lib/components/normal-components/Fuse.ts interpolates the formatted value unconditionally:
display_voltage_rating: `${formatSiUnit(voltageRating)}V`,
...
return `${formatSiUnit(current)}A / ${formatSiUnit(voltage)}V`
formatSiUnit(undefined) returns "", so the template collapses to just the unit suffix.
Prior art in this repo
Resonator._getSchematicSymbolDisplayValue() already handles exactly this shape correctly — it drops the optional half rather than emitting an empty unit:
const freqDisplay = `${formatSiUnit(this._parsedProps.frequency)}Hz`
if (this._parsedProps.loadCapacitance) {
return `${freqDisplay} / ${formatSiUnit(this._parsedProps.loadCapacitance)}F`
}
return freqDisplay
Why no test catches it
tests/components/normal-components/fuse.test.tsx is the only fuse component test and it passes both ratings, so the optional-field path is never exercised.
Interestingly the repo already contains schematic snapshots showing the bug, they just weren't recognised as wrong:
tests/features/schematic-text-bounding-box/schematic-text-bounding-box-fuse.test.tsx— four fuses, allcurrentRating="2A"with no voltage, all rendering2A / V.schematic-section-rp2040.test.tsxandschematic-section-rp2040-autolayout.test.tsx—<fuse name="F1" currentRating="500mA" />, rendering500mA / V.
Happy to submit a PR (already have one ready).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/components/normal-components/Fuse.ts and compare its display formatting with Resonator. Run tests/components/normal-components/fuse.test.tsx, then inspect the mentioned schematic snapshot tests for the missing-voltage case. Done means a fuse with only currentRating no longer emits a bare V in schematic or circuit JSON, with regression coverage for the optional field.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend, testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100