Skip to content

The Receipt Printer tab stops throwing on every click - #773

Merged
sridharkalaibala merged 1 commit into
developfrom
fix/the-receipt-tab-stops-throwing
Sep 15, 2026
Merged

sridharkalaibala merged 1 commit into
developfrom
fix/the-receipt-tab-stops-throwing

Conversation

@sridharkalaibala

Copy link
Copy Markdown
Contributor

"receipt printer previously its multi selct. have you changed anything?"

No — the multi-select was there and working, and my changes to that file
added the word "printer" exactly once, inside a comment.

But checking turned up something worse beside it.

A second printer picker that had never worked

refreshPrinters, selectPrinter, printToSelected and printToDefault wrote
to five elements that have never existed in this file:

#printerStatus   0 occurrences in markup
#printerList     0
#printBtn        0
#printContent    0
#copies          0

git log --follow -S 'id="printerList"' finds no commit that added or removed
them, including before the move into src/. They were never there.

switchTab called it on every receipt-tab click:

if (tabName === 'receipt' && printers.length === 0) refreshPrinters();

and refreshPrinters did statusDiv.classList.remove('hidden') on null,
outside its own try block. So it threw, unhandled, into switchTab. And the
throw came before printers was assigned, so the guard never went false — it
threw again on every single click, for the life of the file. Two of the four
functions were never called by anything at all.

Also removes a listener relabelling #rpDefaultOption, the "default printer"
entry of the old dropdown. Guarded by if (opt), so it never threw — it just
quietly stopped doing anything when the checkbox list replaced the dropdown.
OS_DEFAULT_LABEL stays; the warning about sending a receipt to the system
default still uses it.

The multi-select is untouched: #rpPrinterList, _collectTargets,
receipt_printers saved as a list, and "Tick at least one printer" still
refusing an empty save. Tests pin all four.

Why nothing caught it

tests/tools/dead-selectors.js exists for exactly this class of fault and
could not see it. It matches jQuery $('#id') only, and only inside .js
files under frontend/.../modules/. The shell uses getElementById inside HTML,
which is neither — so src/ was never scanned at all, and the tool reported
"All good" throughout.

So: tests/tools/dead-shell-ids.js, which can be exact where the frontend
one cannot. The shell's pages are self-contained — markup and script in one file
— so the question is not "does anything anywhere create this id" but "does this
file
". No cross-file guessing, no verify-before-deleting caveat.

$ node tests/tools/dead-shell-ids.js          # against the pre-fix file
9 shell page(s) scanned. 6 id(s) asked for and never defined:
  #rpDefaultOption  #printerStatus  #printerList
  #printBtn         #printContent   #copies

$ node tests/tools/dead-shell-ids.js          # against this branch
9 shell page(s) scanned. Every id asked for is defined.

The test proves that rather than asserting it: it builds a page with the same
shape and requires the check to find it. A guard nobody has watched fail is a
guard nobody should trust.

Desktop 2506 pass / 0 fail.

Owner: "receipt printer previously its multi selct. have you changed
anything?"

Nothing had. The multi-select was there and working - #rpPrinterList,
checkboxes, saved as `receipt_printers`. But beside it the same file carried a
SECOND printer picker that had never worked at all.

refreshPrinters, selectPrinter, printToSelected and printToDefault wrote to
#printerStatus, #printerList, #printBtn, #printContent and #copies. Not one of
those elements has ever existed here: `git log --follow -S 'id="printerList"'`
finds no commit that added or removed them, including before the move into
src/.

switchTab called it on every receipt-tab click, and refreshPrinters did
`statusDiv.classList.remove('hidden')` on null OUTSIDE its own try block - so it
threw, unhandled. The throw came BEFORE `printers` was assigned, so the
`printers.length === 0` guard never went false and it threw again on every
single click, for the life of the file. Two of the four functions were never
called by anything at all.

Also removes a listener relabelling #rpDefaultOption, the "default printer"
entry of the old dropdown. Guarded by `if (opt)`, so it never threw; it simply
stopped doing anything when the checkbox list replaced the dropdown, and nothing
said so. OS_DEFAULT_LABEL stays - the warning about sending a receipt to the
system default still uses it.

WHY NOTHING CAUGHT THIS

tests/tools/dead-selectors.js exists for exactly this and could not see it: it
matches jQuery `$('#id')` only, and only inside .js under frontend/.../modules/.
The shell uses getElementById inside HTML, which is neither - so src/ was never
scanned at all, and the tool reported "All good" for the life of the fault.

So tests/tools/dead-shell-ids.js, which can be exact where the frontend one
cannot. The shell's pages are self-contained, markup and script in one file, so
the question is not "does anything anywhere create this id" but "does THIS
file" - no cross-file guessing and no verify-before-deleting caveat. Run against
the pre-fix file it reports all six; against this one, nothing.

The test proves that rather than asserting it: it builds a page with the same
shape and requires the check to find it. A guard nobody has watched fail is a
guard nobody should trust.

Desktop 2506 pass.
@sridharkalaibala
sridharkalaibala merged commit 477c528 into develop Sep 15, 2026
9 checks passed
@github-actions github-actions Bot added the ready for QA Merged to develop and live on develop.posnic.io - anyone can test it label Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Merged to develop. Anyone can test this - you do not need write access.

Try it at https://develop.posnic.io, or run it yourself:

git fetch origin develop && git checkout develop
npm install && npm --prefix api install
npm run dev   # then http://localhost:3000

When you have tested it, say what you did and what happened, and set
QA passed or QA failed. If you cannot set labels, just comment -
a maintainer will.

Reporting that something is broken is as useful as fixing it. It is
better found here than by a shopkeeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for QA Merged to develop and live on develop.posnic.io - anyone can test it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant