Skip to content

fix: notify onStateChange for session settings and tooth notes; keep note badges across grid rebuilds - #26

Merged
ZoliQua merged 3 commits into
ZoliQua:mainfrom
odontodev:fix/notify-on-settings-and-notes
Sep 22, 2026
Merged

ZoliQua merged 3 commits into
ZoliQua:mainfrom
odontodev:fix/notify-on-settings-and-notes

Conversation

@odontodev

@odontodev odontodev commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Three places where a mutation skipped notifyStateChange(), found while persisting the doctor's preferences and the chart from a host app through onStateChange. One commit each, in the order they were found:

1. Session-setting setters

setNotesEnabled, setIcdasEnabled, setCariesDepthEnabled, setSecondaryCariesMode, setRootCariesMode, setRadiographicDepthMode, setWearDetailLevel, setDiscolorationDetailLevel and setNumberingSystem now follow the convention the fillings setters, setPulpDetailLevel and setSurfaceNotation already use: early-return when unchanged, notifyStateChange() on a real change. A host persisting preferences otherwise never sees a toggle made in the Settings modal until the next tooth edit. The onStateChange docstring lists settings now.

One existing test (tooth-details-card.test.tsx) set the wear/discoloration level through the setter before mounting the provider, whose mount effect pushed the default back into the module; the stale DOM masked that while the setters were silent. It now passes the level as a provider prop.

2. Note editor save/delete

The popover wrote state.note — part of the export payload — without notifying, so neither the localStorage autosave nor a host saw a note until the next unrelated edit. Only a real change notifies: re-saving the same text or deleting an empty note is a no-op.

3. Note badges after a grid rebuild

buildGrid() repaints every tooth from state via addTile() but creates the label cells bare, so after a re-init, an anatomy change or a perio round-trip a charted note kept its text and lost its badge. The label rows now get the same treatment.

Tests

  • session-settings-setters.test.ts — one case per setter (notifies on change, silent when unchanged), modelled on filling-settings-setters.test.ts.
  • note-editor-notify.test.tsx — real initOdontogram() under jsdom (same stubs as tier2-rewire): save notifies once and lands in the payload, re-save is silent, delete notifies once, delete-when-empty is silent, badge survives rebuildGrid().
  • Each new case fails on main without its fix. Full suite, tsc -b --noEmit and eslint: clean; no golden changes.

odontodev and others added 3 commits September 20, 2026 15:45
…hange

setNotesEnabled, setIcdasEnabled, setCariesDepthEnabled, setSecondaryCariesMode,
setRootCariesMode, setRadiographicDepthMode, setWearDetailLevel,
setDiscolorationDetailLevel and setNumberingSystem now follow the convention
setPulpDetailLevel/setSurfaceNotation and the fillings setters already use:
early-return when unchanged, notifyStateChange() on a real change.

A host that persists the doctor's preferences through onStateChange otherwise
never sees a toggle made in the Settings modal until the next tooth edit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The note editor popover wrote state.note without notifyStateChange(), so the
note — part of the export payload — reached neither the localStorage autosave
nor a host persisting the chart until the next unrelated edit. Only a real
change notifies; re-saving the same text or deleting an empty note is a no-op.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
buildGrid() repaints every tooth from state through addTile() but creates
the label cells bare, so after a re-init, an anatomy change or a perio
round-trip a charted note kept its text and lost its badge.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

@odontodev is attempting to deploy a commit to the ZoliQua's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-odontogram-modul Ready Ready Preview Sep 22, 2026 5:42am UTC

@ZoliQua
ZoliQua merged commit f3b8da4 into ZoliQua:main Sep 22, 2026
7 checks passed
ZoliQua added a commit that referenced this pull request Sep 22, 2026
…, #27)

Neither PR carried its documentation, which this project requires for a new
public API or a changed behaviour.

- CHANGELOG 2.6.0: an Added entry for the five display settings, their
  controlled props and getNumberingSystem(), and a Fixed entry for the three
  mutations that never reached onStateChange. Both credit @odontodev. The Fixed
  entry also names the consequence the PR did not: onStateChange now fires for
  settings changes, so a subscriber persisting the export payload is woken by a
  Settings toggle that does not change the payload (debounced, one redundant
  write at most).
- All twelve language READMEs: the five props in the props table, six rows in
  the API table (getNumberingSystem plus the five getter/setter pairs), and
  @odontodev's contributor line extended.
- The engine's CLAUDE.md gains a "Session settings" section: where the display
  settings live and the contract every session setter follows (sanitize,
  early-return when unchanged, notify on a real change) — so the next setter
  added does not repeat the omission #26 fixed.

This branch was successfully deployed

1 active deployment
Preview — 32e2bc94 Deployed Sep 22, 2026 by vercel[bot]
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